Class: Google::Cloud::Firestore::FieldValue

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/firestore/field_value.rb

Overview

FieldValue

Represents a change to be made to fields in document data in the Firestore API.

Examples:

require "google/cloud/firestore"

firestore = Google::Cloud::Firestore.new

user_snap = firestore.doc("users/frank").get

# TODO

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.deleteFieldValue

Creates a field value object representing the deletion of a field in document data.

Examples:

require "google/cloud/firestore"

firestore = Google::Cloud::Firestore.new

# Get a document reference
nyc_ref = firestore.doc "cities/NYC"

field_delete = Google::Cloud::Firestore::FieldValue.delete

nyc_ref.update({ name: "New York City",
                 trash: field_delete })

Returns:



84
85
86
# File 'lib/google/cloud/firestore/field_value.rb', line 84

def self.delete
  new :delete
end

.server_timeFieldValue

Creates a field value object representing set a field's value to the server timestamp when accessing the document data.

Examples:

require "google/cloud/firestore"

firestore = Google::Cloud::Firestore.new

# Get a document reference
nyc_ref = firestore.doc "cities/NYC"

field_server_time = Google::Cloud::Firestore::FieldValue.server_time

nyc_ref.update({ name: "New York City",
                 updated_at: field_server_time })

Returns:

  • (FieldValue)

    The server time field value object.



107
108
109
# File 'lib/google/cloud/firestore/field_value.rb', line 107

def self.server_time
  new :server_time
end

Instance Method Details

#typeSymbol

The type of change to make to an individual field in document data.

Examples:

require "google/cloud/firestore"

firestore = Google::Cloud::Firestore.new

# Get a document reference
nyc_ref = firestore.doc "cities/NYC"

field_delete = Google::Cloud::Firestore::FieldValue.delete
field_delete.type #=> :delete

nyc_ref.update({ name: "New York City",
                 trash: field_delete })

Returns:

  • (Symbol)

    The type.



61
62
63
# File 'lib/google/cloud/firestore/field_value.rb', line 61

def type
  @type
end