Reputation: 89
How can I filter from the map in the document?
my query function;
ref
.where('tag_id', isEqualTo: item)
.where('likes', arrayContains: {
Get.find<AuthController>().getCurrentUser!.uid: true
})
.orderBy('created_date', descending: true)
.orderBy('like_count', descending: true)
.orderBy('comment_count', descending: true)
.limit(max.value)
.get();
I want to filter on 'likes' map. I tried to make an example in the code below, but no data is coming. map in document
returning null
Upvotes: 0
Views: 103
Reputation: 598916
Your likes
is not an array, so array-contains
won't work on it.
What you're looking for is :
const uid = Get.find<AuthController>().getCurrentUser!.uid;
ref
.where('tag_id', isEqualTo: item)
.where('likes.$uid', isEqualTo: true)
For more on this dot notation, see the Firebase documentation on updating fields in nested objects.
Upvotes: 1