Let me show you the Firestore document structure.
How I can compare the stops
array values? because time 12:00 PM
will be different for each entry in the departure.
So actually I want to get the value of buss
where the my given value match to any value of the stops
array.
From the Firestore documentation on arrays:
To allow querying for routes that contain a certain stop, you should store an additional field in the document that contains the stops as a set:
Now you can query for routes with that stop by doing:
You'll still need your original structure for the stops too, since that's the only way to know the order of the stops and the time of each stop.
According to @Frank van Puffelen's answer, because Firestore does not support querying array members, you should consider change your database structure a little bit. So instead of using arrays you should use
maps
. So inside each document you need to add amap
that will look like this:As you can see, I have add a new map named
stops
inside the bus document that contains as key, the name of the station and as a value the booleantrue
. Using this database structure you can query your database based on elements that exist inside the map like this: