0

I created a Firestore database. I am learning. How can I access a map into a map, the image help me to explain my doubt.


I can do a query like this in this case scenario:

->recipes
-->idRecipe
--->ingredients
---->0
----->rice
---->1
----->meat

Query query = recipesRef.whereArrayContains("ingredients", "rice");

But how I can do in this case scenario?

Firestore structure:

Firestore structure

How can I find the values of -> ingredient (name:rice)

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
  • You must know the exact object when querying an array of objects. In this case, `{name: 'rice', quantity: '50g'}`. Alternatively, you can store another array of strings that only contain the names of ingredients like `[rice, meat]`. Then you can easily query documents using `where('ingredientsList', 'array-contains', 'rice')`. Check the linked answer for more details. – Dharmaraj Oct 25 '22 at 08:51

0 Answers0