Class: Google::Cloud::Spanner::ColumnValue

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/spanner/column_value.rb

Overview

ColumnValue

Represents a change to be made to a row's column value by the Spanner API.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

# create column value object
commit_timestamp = db.commit_timestamp

db.commit do |c|
  c.insert "users", [
    { id: 5, name: "Murphy", updated_at: commit_timestamp }
  ]
end

Class Method Summary collapse

Class Method Details

.commit_timestampColumnValue

Creates a column value object representing setting a field's value to the timestamp of the commit. (See Google::Cloud::Spanner::Client#commit_timestamp and Transaction#commit_timestamp)

This placeholder value can only be used for timestamp columns that have set the option "(allow_commit_timestamp=true)" in the schema.

Examples:

require "google/cloud/spanner"

spanner = Google::Cloud::Spanner.new

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

# create column value object
commit_timestamp = \
  Google::Cloud::Spanner::ColumnValue.commit_timestamp

db.commit do |c|
  c.insert "users", [
    { id: 5, name: "Murphy", updated_at: commit_timestamp }
  ]
end

Returns:

  • (ColumnValue)

    The commit timestamp column value object.


102
103
104
# File 'lib/google/cloud/spanner/column_value.rb', line 102

def self.commit_timestamp
  new :commit_timestamp
end