Skip to content

Commit 7896c52

Browse files
callmehiphopJustinBeckwith
authored andcommitted
docs: add typedefs for commit timestamp (#356)
1 parent 46670c3 commit 7896c52

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

handwritten/spanner/src/transaction.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,20 @@ class Transaction extends TransactionRequest {
215215
}
216216
);
217217
}
218+
/**
219+
* @typedef {object} CommitResponse
220+
* @property {google.protobuf.Timestamp} commitTimestamp The transaction
221+
* commit timestamp.
222+
*/
223+
/**
224+
* @typedef {array} CommitPromiseResponse
225+
* @property {CommitResponse} 0 The commit response.
226+
*/
227+
/**
228+
* @callback CommitCallback
229+
* @param {?Error} error Request error, if any.
230+
* @param {CommitResponse} apiResponse The full API response.
231+
*/
218232
/**
219233
* Commit the transaction.
220234
*
@@ -225,8 +239,8 @@ class Transaction extends TransactionRequest {
225239
*
226240
* @throws {Error} If transaction has already been ended.
227241
*
228-
* @param {BasicCallback} [callback] Callback function.
229-
* @returns {Promise<BasicResponse>}
242+
* @param {CommitCallback} [callback] Callback function.
243+
* @returns {Promise<CommitPromiseResponse>}
230244
*
231245
* @example
232246
* const {Spanner} = require('@google-cloud/spanner');
@@ -247,9 +261,10 @@ class Transaction extends TransactionRequest {
247261
* });
248262
*
249263
* // Commit the transaction.
250-
* transaction.commit(function(err) {
264+
* transaction.commit(function(err, apiResponse) {
251265
* if (!err) {
252-
* // Mutations were committed successfully.
266+
* // Get the commit timestamp on successful commits.
267+
* const {commitTimestamp} = apiResponse;
253268
* }
254269
* });
255270
* });

0 commit comments

Comments
 (0)