Cloud Spanner API - Class Google::Cloud::Spanner::CommitResponse (v2.23.0)

Reference documentation and code samples for the Cloud Spanner API class Google::Cloud::Spanner::CommitResponse.

CommitResponse is a timestamp at which the transaction committed with additional attributes of commit stats.

Inherits

  • Object

Examples

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

db = spanner.client "my-instance", "my-database"

timestamp = db.commit do |c|
  c.update "users", [{ id: 1, name: "Charlie", active: false }]
  c.insert "users", [{ id: 2, name: "Harvey",  active: true }]
end

puts timestamp

With commit stats.

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

db = spanner.client "my-instance", "my-database"

commit_options = { return_commit_stats: true }
commit_resp = db.commit commit_options: commit_options do |c|
  c.update "users", [{ id: 1, name: "Charlie", active: false }]
  c.insert "users", [{ id: 2, name: "Harvey",  active: true }]
end

puts commit_resp.timestamp
puts commit_resp.stats.mutation_count

Methods

#stats

def stats() -> CommitStats, nil

Additional statistics about a commit.

Returns
  • (CommitStats, nil) — Commit stats or nil if not stats not present.

#timestamp

def timestamp() -> Time

The timestamp at which the transaction committed.

Returns
  • (Time)