Class: Google::Cloud::Spanner::Snapshot
- Inherits:
 - 
      Object
      
        
- Object
 - Google::Cloud::Spanner::Snapshot
 
 
- Defined in:
 - lib/google/cloud/spanner/snapshot.rb
 
Overview
Snapshot
A snapshot in Cloud Spanner is a set of reads that execute atomically at a single logical point in time across columns, rows, and tables in a database.
Instance Method Summary collapse
- 
  
    
      #execute(sql, params: nil, types: nil)  ⇒ Google::Cloud::Spanner::Results 
    
    
      (also: #query)
    
  
  
  
  
  
  
  
  
  
    
Executes a SQL query.
 - 
  
    
      #fields(types)  ⇒ Fields 
    
    
  
  
  
  
  
  
  
  
  
    
Creates a configuration object (Fields) that may be provided to queries or used to create STRUCT objects.
 - 
  
    
      #range(beginning, ending, exclude_begin: false, exclude_end: false)  ⇒ Google::Cloud::Spanner::Range 
    
    
  
  
  
  
  
  
  
  
  
    
Creates a Cloud Spanner Range.
 - 
  
    
      #read(table, columns, keys: nil, index: nil, limit: nil)  ⇒ Google::Cloud::Spanner::Results 
    
    
  
  
  
  
  
  
  
  
  
    
Read rows from a database table, as a simple alternative to #execute.
 - 
  
    
      #timestamp  ⇒ Time 
    
    
  
  
  
  
  
  
  
  
  
    
The read timestamp chosen for snapshots.
 - 
  
    
      #transaction_id  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    
Identifier of the transaction results were run in.
 
Instance Method Details
#execute(sql, params: nil, types: nil) ⇒ Google::Cloud::Spanner::Results Also known as: query
Executes a SQL query.
      217 218 219 220 221 222 223 224  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 217 def execute sql, params: nil, types: nil ensure_session! params, types = Convert.to_input_params_and_types params, types session.execute sql, params: params, types: types, transaction: tx_selector end  | 
  
#fields(types) ⇒ Fields
Creates a configuration object (Fields) that may be provided to queries or used to create STRUCT objects. (The STRUCT will be represented by the Data class.) See Client#execute and/or Fields#struct.
For more information, see Data Types - Constructing a STRUCT.
      345 346 347  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 345 def fields types Fields.new types end  | 
  
#range(beginning, ending, exclude_begin: false, exclude_end: false) ⇒ Google::Cloud::Spanner::Range
Creates a Cloud Spanner Range. This can be used in place of a Ruby Range when needing to exclude the beginning value.
      378 379 380 381 382  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 378 def range beginning, ending, exclude_begin: false, exclude_end: false Range.new beginning, ending, exclude_begin: exclude_begin, exclude_end: exclude_end end  | 
  
#read(table, columns, keys: nil, index: nil, limit: nil) ⇒ Google::Cloud::Spanner::Results
Read rows from a database table, as a simple alternative to #execute.
      261 262 263 264 265 266 267 268 269  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 261 def read table, columns, keys: nil, index: nil, limit: nil ensure_session! columns = Array(columns).map(&:to_s) keys = Convert.to_key_set keys session.read table, columns, keys: keys, index: index, limit: limit, transaction: tx_selector end  | 
  
#timestamp ⇒ Time
The read timestamp chosen for snapshots.
      58 59 60 61  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 58 def return nil if @grpc.nil? Convert. @grpc. end  | 
  
#transaction_id ⇒ String
Identifier of the transaction results were run in.
      50 51 52 53  | 
    
      # File 'lib/google/cloud/spanner/snapshot.rb', line 50 def transaction_id return nil if @grpc.nil? @grpc.id end  |