Firestore array-contains-any is not working properly

后端 未结 1 579
孤独总比滥情好
孤独总比滥情好 2020-12-22 08:10
"@angular/fire": "5.2.3", 
"firebase": "7.4.0",

Note: members is an array and 0,1,

相关标签:
1条回答
  • 2020-12-22 08:47

    The array-contains-any (and also the array-contains) operator check whether the array contains an element that example matches the information that you pass into the call. So in your case, you need to pass in both the id and the joinDateTime in order to match.

    ref.where('members', 'array-contains-any', [{ id: uid, joinedDateTime: ... }])
    

    If you don't know the joinedDateTime for the user, you can't query the array in your current data structure. The normal solution is to store a separate array field memberIds in the document too, which contains just the UIDs of the members. Then you can find the members by querying on that field:

    ref.where('members', 'array-contains', [uid])
    

    Or

    ref.where('members', 'array-contains-any', [uid, uid2, uid3])
    
    0 讨论(0)
提交回复
热议问题