I have a user
collection. Each user has a list of collections with different names, ie "activities", "time", "distance", "sensor-a", "sensor-b", etc. The id of each document in these collections is common. So for example the all the documents with the same id are associated with each other.
Each document in the "activities" collection has properties that I would search on, while "time", "distance", and the "sensor-x" documents are for the most part a list of data points for various sensors. So for example the first element in each list correspond to each other, ie sensor-a[42] is the sensor reading at time[42], distance[42] and sensor-b[42].
So the data looks something like this:
user/100/activites/200
user/100/distance/200
user/100/time/200
user/100/sensor-a/200
user/100/sensor-b/200
user/100/activites/201
user/100/distance/201
user/100/time/201
user/100/sensor-a/201
user/100/sensor-b/201
I would like to be able to filter out a list of "activities" based on some property of the activity and then get all the documents from the other collections that have the same id as those I filtered.
I know I can create a list of ids I am interested in and then simply get each document one at a time but that does not seem very efficient.
I know that Firestore supports an in
query method but that seems to be limited to a maximum of 10 entries, ie my filtered list of activities would need to be 10 or less.
I also see that Firestore has collection groups but they seem to require that all the collections have the same name. I think I could use this but I think I would need to restructure my data, probably adding a level of hierarchy, such as "activities", "distance", and "time" each have a data document that contains the current collections.
Is there any efficient way I can do this query with restructuring my data?