Reputation: 1544
I try to get some lists from cloud firestore with this code
final User user = UserUtils.currentUser(context);
final List<String> memberLists = user.memberLists.toList();
final List<String> ownedLists = user.ownedLists.toList();
final List<String> visibleListsIds = memberLists + ownedLists;
final Query query = (sharedCollection.where(FIELD_LIST_ID, whereIn: visibleListsIds));
log.d("queryPath: ${query.reference().path}");
log.d("buildArguments: ${query.buildArguments()}");
return query.snapshots().map((QuerySnapshot querySnapshot) {
return querySnapshot.documents
.map(
(document) {
log.d("document: ${document.documentID}");
return _getSerializers()
.deserializeWith(WishList.serializer, document.data);
},
)
.where((value) => value != null)
.toList();
});
When I do that I do not get any logs with "document: ..." because obviously the query does not get the documents. Here are the buildArguments of the query:
buildArguments: {where: [[listId, in, [IIAY56KF0mSCx1WwCXaV]]], orderBy: [], path: WISHLISTS}
Note: Wishlists is the correct path and the listId is also correct.
If I change the query line to: final Query query = sharedCollection;
it just spits out all lists, so it should work in theory. I think there is some issue with the whereIn
operator.
Does anyone have a clue why this is not working? I am happy for any help.
Upvotes: 3
Views: 2479
Reputation: 10463
The whereIn
operator uses the same query documented here, and is limited to 10 equality clauses. A workaround here is to split the List visibleListsIds
to smaller chunks, similar to what have been mentioned on this Stack Overflow post.
Upvotes: 1