While I realize we can't query a bunch of docs based on an Array of ID's, I repeatedly find myself needing to do this. This time, I feel it's 100% necessary as I'm looking at selecting what is essentially a random list of ID's. I am wondering how it would be done? I have a random list of ID's of a random length, and need to subscribe and listen to changes on all of them. Anyone know how to do something like this?
Asked
Active
Viewed 707 times
3
-
Possible duplicate of [Google Firestore - how to get document by multiple ids in one round trip?](https://stackoverflow.com/questions/46721517/google-firestore-how-to-get-document-by-multiple-ids-in-one-round-trip) – Frank van Puffelen Mar 12 '19 at 03:48
-
2That question isn't about subscribing, just getting. – Jus10 Mar 12 '19 at 13:39
1 Answers
2
There is no API to register a listener to multiple documents in one call. If you have independent documents to listen to (not obtained by a single query), then will have to register a listener to each one of them separately. You can reuse the same listener object for each one, and check inside it which document the change is for.

Doug Stevenson
- 297,357
- 32
- 422
- 441
-
1Follow-up question: Does doing this (subscribing and listening to each document individually) end up costing more $$ in Firestore reads than it would if I was to query it normally (Trying to decide if restructuring my data to make this easier is worth the trouble) – Jus10 Mar 12 '19 at 00:12
-
I don't see how it would, given the descriptions on the pricing page about listeners. – Doug Stevenson Mar 12 '19 at 00:15
-
Ok ya that's what it looks like, but a second opinion really helps. Thanks again! – Jus10 Mar 12 '19 at 00:19