Cloud Spanner API - Class Google::Cloud::Spanner::Results (v2.17.0)

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

Results

Represents the result set from an operation returning data.

See Client#execute_query and Client#read.

Inherits

  • Object

Example

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

results = db.execute_query "SELECT * FROM users"

results.fields.pairs.each do |name, type|
  puts "Column #{name} is type #{type}"
end

Methods

#fields

def fields() -> Fields

Returns the configuration object (Fields) of the names and types of the rows in the returned data.

Returns
  • (Fields) — The fields of the returned data.
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

results = db.execute_query "SELECT * FROM users"

results.fields.pairs.each do |name, type|
  puts "Column #{name} is type #{type}"
end

#rows

def rows() { |row| ... }

The values returned from the request.

Yields
  • (row) — An enumerator for the rows.
Yield Parameter
  • row (Data) — object that contains the data values.
Example
require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

results = db.execute_query "SELECT * FROM users"

results.rows.each do |row|
  puts "User #{row[:id]} is #{row[:name]}"
end

#timestamp

def timestamp() -> Time

The read timestamp chosen for single-use snapshots (read-only transactions).

Returns
  • (Time) — The chosen timestamp.