0

My Firestore structure is shown in the picture

enter image description here

My Firestore document has many documents and one of them is shown the picture. In my Android App I want to query all the documents which has the values "3P", "Urgent" and "Mission Challenge". That means if a document has "3P", "Urgent" and "Mission Challenge" then this document should be my query result. If a document has only "3P" but not other values(like "Urgent", "Mission Challenge") then it should not come in my query result. How to do this in Firestore.

Bhaskar Jyoti Dutta
  • 1,740
  • 2
  • 15
  • 30

1 Answers1

1

I don't think it's possible to perform something like 'array-contains-all' in Firestore yet. @Doug had an answer for a similar case.

You can use at most one array-contains clause per query.

The best way for now would be using maps and using multiple whereEqualTo methods:

db.collection("dungeon")
    .whereEqualTo("textMap.3P", true)
    .whereEqualTo("textMap.urgent", true)
    .whereEqualTo("textMap.mission_challenge", true)
    .get()

The document:

{
  ...otherFields,
  textMap: {
    "urgent": true,
    ...otherMapFields
  }
}
Dharmaraj
  • 47,845
  • 8
  • 52
  • 84