Class: Google::Cloud::Datastore::Commit
- Inherits:
-
Object
- Object
- Google::Cloud::Datastore::Commit
- Defined in:
- lib/google/cloud/datastore/commit.rb
Overview
Commit
Object yielded from commit
methods to allow multiple changes to be
made in a single commit.
See Dataset#commit and Transaction#commit.
Instance Method Summary collapse
-
#delete(*entities_or_keys) ⇒ Object
Remove entities from the Datastore.
-
#insert(*entities) ⇒ Object
Inserts entities to the Datastore.
-
#save(*entities) ⇒ Object
(also: #upsert)
Saves entities to the Datastore.
-
#update(*entities) ⇒ Object
Updates entities to the Datastore.
Instance Method Details
#delete(*entities_or_keys) ⇒ Object
Remove entities from the Datastore.
116 117 118 119 120 121 122 123 |
# File 'lib/google/cloud/datastore/commit.rb', line 116 def delete *entities_or_keys keys = Array(entities_or_keys).flatten.map do |e_or_k| e_or_k.respond_to?(:key) ? e_or_k.key : e_or_k end @shared_deletes += keys unless keys.empty? # Do not delete yet true end |
#insert(*entities) ⇒ Object
Inserts entities to the Datastore.
77 78 79 80 81 82 |
# File 'lib/google/cloud/datastore/commit.rb', line 77 def insert *entities entities = Array(entities).flatten @shared_inserts += entities unless entities.empty? # Do not insert yet entities end |
#save(*entities) ⇒ Object Also known as: upsert
Saves entities to the Datastore.
57 58 59 60 61 62 |
# File 'lib/google/cloud/datastore/commit.rb', line 57 def save *entities entities = Array(entities).flatten @shared_upserts += entities unless entities.empty? # Do not save yet entities end |
#update(*entities) ⇒ Object
Updates entities to the Datastore.
96 97 98 99 100 101 |
# File 'lib/google/cloud/datastore/commit.rb', line 96 def update *entities entities = Array(entities).flatten @shared_updates += entities unless entities.empty? # Do not update yet entities end |