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

2.36.0 (latest) 2.35.0 2.34.0 2.33.0 2.32.0 2.31.0 2.30.0 2.29.0 2.28.0 2.27.0 2.26.0 2.25.0 2.24.0 2.23.0 2.22.0 2.21.0 2.20.0 2.19.1 2.18.1 2.17.0 2.16.1 2.15.0 2.14.0 2.13.0 2.12.1 2.11.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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Client#Google__Cloud__Spanner__Client_execute_query_instance_ "Google::Cloud::Spanner::Client#execute_query (method)") and
[Client#read](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Client#Google__Cloud__Spanner__Client_read_instance_ "Google::Cloud::Spanner::Client#read (method)").

## Inherits

- Object

## Example

```ruby
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

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

## Methods

### #fields

    def fields() -> Fields

Returns the configuration object ([Fields](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Fields "Google::Cloud::Spanner::Fields (class)")) of the names and types of
the rows in the returned data.
**Returns**

- ([Fields](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Fields)) --- The fields of the returned data.
**Example**

```ruby
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](https://docs.cloud.google.com/ruby/docs/reference/google-cloud-spanner/latest/Google-Cloud-Spanner-Data)) --- object that contains the data values.
**Example**

```ruby
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.