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

docs: add typedefs for commit timestamp #356

Merged
merged 1 commit into from
Oct 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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