Firestore Query Across Multiple Fields for Same Value

前端 未结 2 593
孤城傲影
孤城傲影 2021-01-16 09:45

Is it possible to query multiple fields in a firestore document for the same value?

Imagine I have numerous documents where each described a sport:

s         


        
2条回答
  •  生来不讨喜
    2021-01-16 10:07

    One way to do something like that would be to restructure your data like so:

    ["bowling" : [
    "ball": true, "bowling alley": true, "bowling shoes": true,
    "description": "bowl the ball" ]]
    

    and then query for documents where "ball" is equal to true:

    Firestore.firestore().collection("sports").whereField("ball", isEqualTo: true)
    

提交回复
热议问题