Firestore in Datastore mode API - Class Google::Cloud::Datastore::Commit (v2.7.1)

Reference documentation and code samples for the Firestore in Datastore mode API class Google::Cloud::Datastore::Commit.

Commit

Object yielded from commit methods to allow multiple changes to be made in a single commit.

See Dataset#commit and Transaction#commit.

Inherits

  • Object

Example

require "google/cloud/datastore"

datastore = Google::Cloud::Datastore.new

datastore.commit do |c|
  c.save task3, task4
  c.delete task1, task2
end

Methods

#delete

def delete(*entities_or_keys)

Remove entities from the Datastore.

Parameter
  • entities_or_keys (Entity, Key) — One or more Entity or Key objects to remove.
Example
require "google/cloud/datastore"

datastore = Google::Cloud::Datastore.new

datastore.commit do |c|
  c.delete task1, task2
end

#insert

def insert(*entities)

Inserts entities to the Datastore.

Parameter
  • entities (Entity) — One or more Entity objects to insert.
Example
require "google/cloud/datastore"

datastore = Google::Cloud::Datastore.new

datastore.commit do |c|
  c.insert task1, task2
end

#save

def save(*entities)
Aliases

Saves entities to the Datastore.

Parameter
  • entities (Entity) — One or more Entity objects to save.
Example
require "google/cloud/datastore"

datastore = Google::Cloud::Datastore.new

datastore.commit do |c|
  c.save task1, task2
end

#update

def update(*entities)

Updates entities to the Datastore.

Parameter
  • entities (Entity) — One or more Entity objects to update.
Example
require "google/cloud/datastore"

datastore = Google::Cloud::Datastore.new

datastore.commit do |c|
  c.update task1, task2
end

#upsert

def upsert(*entities)
Alias Of: #save

Saves entities to the Datastore.

Parameter
  • entities (Entity) — One or more Entity objects to save.
Example
require "google/cloud/datastore"

datastore = Google::Cloud::Datastore.new

datastore.commit do |c|
  c.save task1, task2
end