Skip to content
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

firestore DocumentReference.update does not support Preconditions #48

Open
whesse opened this issue Jul 17, 2019 · 1 comment
Open

firestore DocumentReference.update does not support Preconditions #48

whesse opened this issue Jul 17, 2019 · 1 comment

Comments

@whesse
Copy link

whesse commented Jul 17, 2019

The node.js API for DocumentReference.update allows an optional second argument, Preconditions. This is missing from the firebase-admin-interop implementation.

The Dart package implements the Precondition object, documents it as used in Transaction, DocumentReference, and WriteBatch, but it is only available in the Transaction.update call, not the other two.

The firestore_binding js DocumentReference collection seems to declare the JS call with the correct arguments:
external Promise update(UpdateData data, [Precondition precondition]);
So it seems like the Dart DocumentReference implementation could just call
nativeInstance.update(docData, _getNativePrecondition(lastUpdateTime))
in the case that an optional Timestamp is passed to it, as is the case with Transaction.

I would like to update documents from DocumentReference, but be sure that I am not overwriting other's changes.

@whesse
Copy link
Author

whesse commented Jul 18, 2019

It turns out that for my use case, Transaction is the correct thing to use. Since I am reading a document, and updating it based on the read values, and don't want other writes inbetween, Transaction gives me this guarantee, and automatically retries when there is a conflict, so it has all I need built in to it. So this bug is not a blocker for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant