-
Notifications
You must be signed in to change notification settings - Fork 1.6k
FR: Add something like batchGet to Firestore SDK #1877
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for taking the time to write in. We're well aware of this function :-). The Firestore mobile and web clients use the streaming API to do all their work (see Listen in the protocol). This API forms the foundation of our synchronization mechanism: when you run a query the client supplies a resume token that describes the last time the query was run and the server can send us only the changes. Additionally, the Listen protocol allows for multiple queries to be active at once, integrating them into a single consistent snapshot with each update. This means that when a document changes if it matches multiple active queries the change is only sent once. The protocol also provides a means of verifying cache coherence. The batch get RPC doesn't fit this model:
There are two paths forward on this:
At this point we're planning on (1). It's on our backlog, but other features are prioritized higher. For now my advice is to just do the loop. |
This seems really useful as I have data models that store identifiers for other documents and cannot find a simple way to query or fetch multiple records at once unless I'm missing something. |
You're not missing anything, but at some point realize that Firestore isn't a traditional database, and structuring your data in a way that requires a join is cutting across the grain. If you referenced data is relatively static you may find it easier to denormalize some or all of it into the referring document. In any case, as I said above, we recognize the value of this operation, but can't prioritize this higher than other work. |
Yeah I would have liked to do that but the data as you say may not be static and updates would need to touch many records possibly. Will be great when this gets in. |
Not the greatest solution, but at least I can say "Well, Google told me to do it." about the denormalized document. 😄Thanks! (Not being sarcastic.) |
@wilhuff Any update on this? Around priority or timing? |
@eminisrafil the Firestore SDK team's recent work has largely been focused on adding support for C++/Unity, and this will likely continue until those platforms' support reaches GA. The priority of this issue has not been increased and thus far no significant progress has been made. |
Sometimes one comes in the situation where you get back multiple document from a query and each document has a reference saved in the field.
Now you want to get those (and only those documents), want you end up doing is either:
Both are not the most ideal ways so I looked for an alternative, I knew that there were batches, but they are only for writing, so I dig deeper and ended up at this Firestore REST API page:
There is a function called
batchGet
https://firebase.google.com/docs/firestore/reference/rest/v1beta1/projects.databases.documents/batchGetAs far as I know this function is not yet implemented in the Firestore SDKs and there is no open issue for that.
Is there any issue with the offline functionality of Firestore and because of that this is not implemented?
The text was updated successfully, but these errors were encountered: