class Google::Cloud::Spanner::CommitResponse
CommitResponse
is a timestamp at which the transaction committed with additional attributes of commit stats.
@example
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
@example 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
Public Class Methods
from_grpc(grpc)
click to toggle source
@private Creates a new Commit
responsee instance from a `Google::Cloud::Spanner::V1::CommitResponse`.
# File lib/google/cloud/spanner/commit_response.rb, line 81 def self.from_grpc grpc new grpc end
new(grpc)
click to toggle source
@private Creates a new CommitResponse
instance.
# File lib/google/cloud/spanner/commit_response.rb, line 58 def initialize grpc @grpc = grpc end
Public Instance Methods
stats()
click to toggle source
Additional statistics about a commit. @return [CommitStats, nil] Commit
stats or nil if not stats not
present.
# File lib/google/cloud/spanner/commit_response.rb, line 73 def stats CommitStats.from_grpc @grpc.commit_stats if @grpc.commit_stats end
timestamp()
click to toggle source
The timestamp at which the transaction committed. @return [Time]
# File lib/google/cloud/spanner/commit_response.rb, line 65 def timestamp Convert.timestamp_to_time @grpc.commit_timestamp end