admin管理员组文章数量:1125796
I have the code
QuerySnapshot snapshot = await FirebaseFirestore.instance
.collection('Posts')
.where('groupId', whereIn: [
'oVF05dlEdzS3vdj3TvSG'
]) // Using whereIn for multiple groups
.orderBy('createdAtTimestamp', descending: true)
.startAfterDocument(_lastDocument!)
.limit(_numberOfPosts)
.get();
This query worked fine before i added this .where filter looking at groupIds.
I then added a groupId filter and used a group as an example. I currently have one Post document that has the groupId as you can see with the exact same id. Why is it returning 0 posts? Is there something I'm missing?
There will only be 5 groups max so its ok.
I have the code
QuerySnapshot snapshot = await FirebaseFirestore.instance
.collection('Posts')
.where('groupId', whereIn: [
'oVF05dlEdzS3vdj3TvSG'
]) // Using whereIn for multiple groups
.orderBy('createdAtTimestamp', descending: true)
.startAfterDocument(_lastDocument!)
.limit(_numberOfPosts)
.get();
This query worked fine before i added this .where filter looking at groupIds.
I then added a groupId filter and used a group as an example. I currently have one Post document that has the groupId as you can see with the exact same id. Why is it returning 0 posts? Is there something I'm missing?
There will only be 5 groups max so its ok.
Share Improve this question edited Jan 9 at 4:16 Frank van Puffelen 598k84 gold badges887 silver badges858 bronze badges Recognized by Google Cloud Collective asked Jan 9 at 3:24 splurringsplurring 836 bronze badges1 Answer
Reset to default 2The whereIn
clause checks if a single-value field has one of multiple possible values.
Your groupId
is an array field, so you need to use arrayContains
:
.where('groupId', arrayContains: 'oVF05dlEdzS3vdj3TvSG')
Also see the Firebase documentation on querying by array membership.
本文标签: Flutter Firebase Query whereIn filter returning 0 postsStack Overflow
版权声明:本文标题:Flutter Firebase Query: whereIn filter returning 0 posts - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736674518a1947109.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论