class Google::Cloud::Firestore::CommitResponse
The response for a commit.
@example
require "google/cloud/firestore" firestore = Google::Cloud::Firestore.new commit_response = firestore.batch do |b| # Set the data for NYC b.set("cities/NYC", { name: "New York City" }) # Update the population for SF b.update("cities/SF", { population: 1000000 }) # Delete LA b.delete("cities/LA") end puts commit_response.commit_time commit_response.write_results.each do |write_result| puts write_result.update_time end
Attributes
commit_time[RW]
The time at which the commit occurred.
@return [Time] The commit time.
write_results[RW]
The result of applying the writes.
This i-th write result corresponds to the i-th write in the request.
@return [Array<CommitResponse::WriteResult>] The write results.
Public Class Methods
from_grpc(grpc, writes)
click to toggle source
@private
# File lib/google/cloud/firestore/commit_response.rb, line 72 def self.from_grpc grpc, writes return new if grpc.nil? commit_time = Convert.timestamp_to_time grpc.commit_time all_write_results = Array(grpc.write_results) write_results = writes.map do |write| update_time = nil Array(write).count.times do write_grpc = all_write_results.shift if write_grpc update_time ||= Convert.timestamp_to_time write_grpc.update_time end end update_time ||= commit_time WriteResult.new.tap do |write_result| write_result.instance_variable_set :@update_time, update_time end end new.tap do |resp| resp.instance_variable_set :@commit_time, commit_time resp.instance_variable_set :@write_results, write_results end end
new()
click to toggle source
@private
# File lib/google/cloud/firestore/commit_response.rb, line 51 def initialize @commit_time = nil @write_results = [] end