lib/google/cloud/firestore/transaction.rb in google-cloud-firestore-2.8.0 vs lib/google/cloud/firestore/transaction.rb in google-cloud-firestore-2.9.0

- old
+ new

@@ -680,14 +680,16 @@ @closed end ## # @private New Transaction reference object from a path. - def self.from_client client, previous_transaction: nil + def self.from_client client, previous_transaction: nil, read_time: nil, read_only: nil new.tap do |s| s.instance_variable_set :@client, client s.instance_variable_set :@previous_transaction, previous_transaction + s.instance_variable_set :@read_time, read_time + s.instance_variable_set :@read_only, read_only end end ## # @private The Service object. @@ -736,20 +738,26 @@ end ## # @private def transaction_opt + read_only = \ + Google::Cloud::Firestore::V1::TransactionOptions::ReadOnly.new \ + read_time: service.read_time_to_timestamp(@read_time) + read_write = \ Google::Cloud::Firestore::V1::TransactionOptions::ReadWrite.new if @previous_transaction read_write.retry_transaction = @previous_transaction @previous_transaction = nil end - Google::Cloud::Firestore::V1::TransactionOptions.new( - read_write: read_write - ) + if @read_only + Google::Cloud::Firestore::V1::TransactionOptions.new read_only: read_only + else + Google::Cloud::Firestore::V1::TransactionOptions.new read_write: read_write + end end ## # @private def extract_transaction_from_result! result