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
- login With OAuth Failed
login With OAuth Failed: when i cliick to login with any of the following (facebook, gmail or apple) am being redirected out of the app to enter my detail, afte...
- Flutter OAuth2 webAuth Bug?
I created with flutter an app where I can login in with my Microsoft Account. When I compile it to Web (WASM) or Android (aab) then there is no problem what so ...
- Synchronous Function Execution Timed Out...
Hi Appwrite team π Iβm facing a synchronous function execution timeout issue on Appwrite Cloud and would appreciate some guidance. I executed this function u...