Open
Conversation
|
|
benjie
previously requested changes
May 10, 2021
examples/CloudFirestore.md
Outdated
| .collection(`users`) | ||
| .where(admin.firestore.FieldPath.documentId(), `in`, keys) | ||
| .get(); | ||
| return snapshot.docs.map((doc) => ({ ...doc.data(), id: doc.id })); |
Member
There was a problem hiding this comment.
Does firestore guarantee the results will be in the same order as the keys input? If you're not sure this is the case, I think it might be safer if this line was something like:
Suggested change
| return snapshot.docs.map((doc) => ({ ...doc.data(), id: doc.id })); | |
| return keys.map(key => { | |
| const doc = snapshot.docs.find(doc => doc.id === key); | |
| return doc ? { ...doc.data(), id: doc.id } : null; | |
| }); |
(Obviously test this works before adopting it; I've never used Firestore.)
Author
There was a problem hiding this comment.
@benjie
Thank you for your review.
As you said, firestore is retrieved in ascending order by document ID by default, so I think sorting by input key is necessary.
I have added the correction and comments.
I have also implemented and confirmed the test in my repository.
Member
|
@saihaj Alas I use neither DataLoader nor Firestore so cannot really review the PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DataLoader is a great feature.
I'm using Cloud Firestore, and I've thrown in a pull request to add sample documentation, which I hope will increase the number of Cloud Firestore use cases.