Module: Mongoid::Contextual::Atomic
- Defined in:
- lib/mongoid/contextual/atomic.rb
Instance Method Summary collapse
-
#add_to_set(field, value) ⇒ nil
Execute an atomic $addToSet on the matching documents.
-
#bit(field, value) ⇒ nil
Perform an atomic $bit operation on the matching documents.
-
#inc(field, value) ⇒ nil
Perform an atomic $inc operation on the matching documents.
-
#pop(field, value) ⇒ nil
Perform an atomic $pop operation on the matching documents.
-
#pull(field, value) ⇒ nil
Perform an atomic $pull operation on the matching documents.
-
#pull_all(field, values) ⇒ nil
Perform an atomic $pullAll operation on the matching documents.
-
#push(field, value) ⇒ nil
Perform an atomic $push operation on the matching documents.
-
#push_all(field, values) ⇒ nil
Perform an atomic $pushAll operation on the matching documents.
-
#rename(old_name, new_name) ⇒ nil
Perform an atomic $rename of fields on the matching documents.
-
#set(field, value) ⇒ nil
Perform an atomic $set of fields on the matching documents.
-
#unset(*args) ⇒ nil
Perform an atomic $unset of a field on the matching documents.
Instance Method Details
#add_to_set(field, value) ⇒ nil
Execute an atomic $addToSet on the matching documents.
17 18 19 |
# File 'lib/mongoid/contextual/atomic.rb', line 17 def add_to_set(field, value) query.update_all("$addToSet" => { database_field_name(field) => value }) end |
#bit(field, value) ⇒ nil
Perform an atomic $bit operation on the matching documents.
33 34 35 |
# File 'lib/mongoid/contextual/atomic.rb', line 33 def bit(field, value) query.update_all("$bit" => { database_field_name(field) => value }) end |
#inc(field, value) ⇒ nil
Perform an atomic $inc operation on the matching documents.
48 49 50 |
# File 'lib/mongoid/contextual/atomic.rb', line 48 def inc(field, value) query.update_all("$inc" => { database_field_name(field) => value }) end |
#pop(field, value) ⇒ nil
Perform an atomic $pop operation on the matching documents.
68 69 70 |
# File 'lib/mongoid/contextual/atomic.rb', line 68 def pop(field, value) query.update_all("$pop" => { database_field_name(field) => value }) end |
#pull(field, value) ⇒ nil
Expression pulling is not yet supported.
Perform an atomic $pull operation on the matching documents.
85 86 87 |
# File 'lib/mongoid/contextual/atomic.rb', line 85 def pull(field, value) query.update_all("$pull" => { database_field_name(field) => value }) end |
#pull_all(field, values) ⇒ nil
Perform an atomic $pullAll operation on the matching documents.
100 101 102 |
# File 'lib/mongoid/contextual/atomic.rb', line 100 def pull_all(field, values) query.update_all("$pullAll" => { database_field_name(field) => values }) end |
#push(field, value) ⇒ nil
Perform an atomic $push operation on the matching documents.
115 116 117 |
# File 'lib/mongoid/contextual/atomic.rb', line 115 def push(field, value) query.update_all("$push" => { database_field_name(field) => value }) end |
#push_all(field, values) ⇒ nil
Perform an atomic $pushAll operation on the matching documents.
130 131 132 |
# File 'lib/mongoid/contextual/atomic.rb', line 130 def push_all(field, values) query.update_all("$pushAll" => { database_field_name(field) => values }) end |
#rename(old_name, new_name) ⇒ nil
Perform an atomic $rename of fields on the matching documents.
145 146 147 |
# File 'lib/mongoid/contextual/atomic.rb', line 145 def rename(old_name, new_name) query.update_all("$rename" => { database_field_name(old_name) => new_name.to_s }) end |
#set(field, value) ⇒ nil
Perform an atomic $set of fields on the matching documents.
160 161 162 |
# File 'lib/mongoid/contextual/atomic.rb', line 160 def set(field, value) query.update_all("$set" => { database_field_name(field) => value }) end |
#unset(*args) ⇒ nil
Perform an atomic $unset of a field on the matching documents.
174 175 176 177 |
# File 'lib/mongoid/contextual/atomic.rb', line 174 def unset(*args) fields = args.__find_args__.collect { |f| [database_field_name(f), true] } query.update_all("$unset" => Hash[fields]) end |