Skip to content

Commit

Permalink
docs: add typedefs for commit timestamp (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
callmehiphop authored and JustinBeckwith committed Oct 3, 2018
1 parent 8a3be8b commit 1e0c5e0
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,20 @@ class Transaction extends TransactionRequest {
}
);
}
/**
* @typedef {object} CommitResponse
* @property {google.protobuf.Timestamp} commitTimestamp The transaction
* commit timestamp.
*/
/**
* @typedef {array} CommitPromiseResponse
* @property {CommitResponse} 0 The commit response.
*/
/**
* @callback CommitCallback
* @param {?Error} error Request error, if any.
* @param {CommitResponse} apiResponse The full API response.
*/
/**
* Commit the transaction.
*
Expand All @@ -225,8 +239,8 @@ class Transaction extends TransactionRequest {
*
* @throws {Error} If transaction has already been ended.
*
* @param {BasicCallback} [callback] Callback function.
* @returns {Promise<BasicResponse>}
* @param {CommitCallback} [callback] Callback function.
* @returns {Promise<CommitPromiseResponse>}
*
* @example
* const {Spanner} = require('@google-cloud/spanner');
Expand All @@ -247,9 +261,10 @@ class Transaction extends TransactionRequest {
* });
*
* // Commit the transaction.
* transaction.commit(function(err) {
* transaction.commit(function(err, apiResponse) {
* if (!err) {
* // Mutations were committed successfully.
* // Get the commit timestamp on successful commits.
* const {commitTimestamp} = apiResponse;
* }
* });
* });
Expand Down

0 comments on commit 1e0c5e0

Please sign in to comment.