
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
- Bulk API upsert or Create documents func...
Hi , I keep getting “databases.upsertDocuments” or “createDocuments” function is not a valid appwrite function error . Following is a simple node.js code (modi...
- Google Oath2 for Flutter Android App not...
I have this function in my auth file for logging in via google Future<void> loginWithGoogle() async { try { final result = await FlutterWebAuth2.aut...
- OAuth2 and Email/Passwort is not working...
Hello guys, after updating to the latest Appwrite Flutter package (17.0.1) I am facing completely weird behavior. None of my login ways are working. Whether the...
