ThyR4n
ThyR4n

Reputation: 105

Create Firestore query dependend on collection inside document

I have a firestore db that looks like this:

dummy_collection:{
                  id: {
                       data: {...},
                       metaData: {
                                  date: "2020-06-15",
                                   ...
                                 },
                      },
                 },

I want to make a query based on the date-field.

I tried with:

db.collection("dummy_collection").where("metaData/date", "==", "2020-06-15")

but received:

ValueError: Path metaData/date not consumed, residue: /date

Is a query like this possible with firestore?

Upvotes: 1

Views: 100

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 598658

Nested fields are addressed with a ., not with a /. So:

db.collection("dummy_collection").where("metaData.date", "==", "2020-06-15")

Also see the documentation on updating fields in nested objects, which is the only in the documentation that I know mentioned the . notation

Upvotes: 1

Related Questions