
i want to fetch user followers from database and i double checked everything but still not able to get the list. here's my user_api code . there could be a mistake in query i guess -
Future<List<model.Document>> getFollowers(String uid) async {
final documents = await _db.listDocuments(
databaseId: AppConstants.APPWRITE_DATABASE_ID,
collectionId: AppConstants.APPWRITE_USERS_COLLECIION,
queries: [
Query.equal('followers', uid)
]
);
return documents.documents;
}```

it looks good, have you created an index on followers field?

and could you pls send the error message

here's my controller code -
Future<List<UserModel>> getFollowers(String uid) async {
final followersDocs = await _userAPI.getFollowers(uid);
return followersDocs.map((e) => UserModel.fromMap(e.data)).toList();
}

provider - final getFollowersProvider = FutureProvider.family((ref, String uid) async{
final UserProfileController = ref.watch(userProfileControllerProvider.notifier);
return UserProfileController.getFollowers(uid);
});

and here i am displaying - ref.watch(getFollowersProvider(user.uid)).when(
data: (followers) {
print('Followers Count: ${followers.length}');
print('User UID: ${user.uid}');
return ListView.builder(
itemCount: followers.length,
itemBuilder: (BuildContext context, int index) {
final follower = followers[index];
return SearchTile(userModel: follower);
},
);
},
error: (error, st) => ErrorText(error: error.toString()),
loading: () => const Loader(),
),

followers present in my usermodel - class UserModel {
final String email;
final String name;
final List<String> followers;

and there's no error. the list is just not displaying. and printing followers.length = 0

I think i am using wrong query because the followers are in list but idk what would be the right query to use

as here followers field is a list its still wip here you can see an issue about the same https://github.com/appwrite/appwrite/issues/2838

you can trying using Query.search (as mention in one of the comments it kinda works) or filter in the client side as per the requirment

i tried using query.search. still not working :_

Yes i tried using listDocument its not working, also not getting desired attribute data

rn something like Query.contains is not present to search from a list but you can do filter it in the client side π

whats exactly not working for you @Pradhumansinh Padhiyar

Something like
SELECT username, email, password, firstname, lastname from tbl_users WHERE lastname = "Ranjan"
How can i achieve something like this using Db collection ?

add a query as Query.equal('lastname', 'Ranjan') and make a index for the lastname parameter in the appwrite console

how could i do that?

actually depends on what exactly you are tying to do

Some days Ago I am also Facing this issue You need To Specify your attribute into the indexes Section
Recommended threads
- Redirect URL sends HTTP instead of HTTPS...
I am not sure since when this issue is present, but my Google and Apple redirect URI are no longer pointing to the HTTPS redirect URI when I try to use OAuth. ...
- Failing to run document operations on sd...
Could someone point me in the right direction I'm going in cirlces. I have a problem with sdks and my self-hosted server in production (for ~3 years) I have bee...
- Functions fail to deploy after switching...
Hi <@1087889306208718959> , after switching my self-hosted Appwrite instance to use AWS S3 as the storage backend, my Cloud Functions stopped working. Iβm runni...
