-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: add read-only transactions #1541
Conversation
types/firestore.d.ts
Outdated
* document. A transaction releases its document locks at commit time or if | ||
* it fails for any reason. | ||
* | ||
* Read-only transaction do not lock documents. They can be used to read |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/transaction/transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
dev/src/index.ts
Outdated
* writes, and other non-transactional writes from changing that document. | ||
* A transaction releases its document locks at commit time or once it times | ||
* out or fails for any reason. | ||
* Transaction can be performed as read-only or read-write transactions. By |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/Transaction/Transactions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
readOnly = true; | ||
readTime = transactionOptions.readTime as Timestamp | undefined; | ||
maxAttempts = 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: specify that read-only transactions not retried in the documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (might make sense for you to do a quick sanity check on the result)
expect(snapshot.get('foo')).to.equal(1); | ||
}); | ||
|
||
it('fails read-only with writes', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: verify that the tx was not retried.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Sebastian goes above and beyond"
types/firestore.d.ts
Outdated
@@ -174,6 +174,28 @@ declare namespace FirebaseFirestore { | |||
[key: string]: any; // Accept other properties, such as GRPC settings. | |||
} | |||
|
|||
/** Options to configure a read-only transaction. */ | |||
export interface ReadOnlyTransactionOptions { | |||
/** Set to true to indicate a read-write transaction. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/read-write/read-only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
types/firestore.d.ts
Outdated
|
||
/** Options to configure a read-write transaction. */ | ||
export interface ReadWriteTransactionOptions { | ||
/** Set to false or omitted to start a read-write transaction. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/start/indicate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
🤖 I have created a release \*beep\* \*boop\* --- ## [4.13.0](https://github.com/googleapis/nodejs-firestore/compare/v4.12.3...v4.13.0) (2021-06-29) ### Features * add read-only transactions ([#1541](https://github.com/googleapis/nodejs-firestore/issues/1541)) ([ca4241e](https://github.com/googleapis/nodejs-firestore/commit/ca4241eb3ee4abb8453b6da0911397187dc18dde)) * retry BatchGetDocuments RPCs that fail with errors ([#1544](https://github.com/googleapis/nodejs-firestore/issues/1544)) ([b39dd3c](https://github.com/googleapis/nodejs-firestore/commit/b39dd3c65549fb1a651c1722d8ea2c038e152417)) ### Bug Fixes * **deps:** google-gax v2.17.0 with mTLS ([#1546](https://github.com/googleapis/nodejs-firestore/issues/1546)) ([a322345](https://github.com/googleapis/nodejs-firestore/commit/a32234510d487982b950c88575b9425c531c2d94)) * make request optional in all cases ([#1536](https://github.com/googleapis/nodejs-firestore/issues/1536)) ([f6edfc1](https://github.com/googleapis/nodejs-firestore/commit/f6edfc181ca39cd307eab6d141db08f377d5cfdf)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This adds read-only transactions to Firestore Node. They are already available in Java.
Fixes #1245