Reputation: 3054
I have data in Firestore as (Collection) Movies -> (Document) MovieId -> (Array).
Each movie document can have many arrays which are named in a date format MM-DD-YYYY. My question is, is there any way to query these arrays by their name? Considering the name is current date.
For example if I want to run a cloud function that gives me all the today's date array from all the movies?
Something like below...
var moviesRef = db.collection('movies');
var query = moviesRef.where("01-16-2019", "==", "01-16-2019");
The 01-16-2019 is my array name.
Thanks in advance
Upvotes: 0
Views: 183
Reputation: 317427
You can't do this the way your data is structured. Array type fields can only be queried by their entire contents for equality (whole list to whole list comparison), or for a single element in the array by its exact value using array-contains.
You can't query a document based on the mere existence of a field either.
If you want to query these documents by some date, you will need to add those dates as the members of an array or a fields of an object whose values map to something like 'true'.
Upvotes: 2