| Class | Mongo::Protocol::Update |
| In: |
lib/mongo/protocol/update.rb
|
| Parent: | Message |
MongoDB Wire protocol Update message.
This is a client request message that is sent to the server in order to update documents matching the provided query.
The default is to update a single document. In order to update many at a time users should set the +:multi_update+ flag for the update.
If an upsert (update or insert) is desired, users can set the +:upsert+ flag in order to indicate they would like to insert the merged selector and update if no document matching the update query currently exists.
@api semipublic
| upconverter | [R] |
@example Update single document
Update.new('xgen', 'users', {:name => 'Tyler'}, {:name => 'Bob'})
@example Perform a multi update
Update.new('xgen', 'users',
{:age => 20}, {:age => 21}, :flags => [:multi_update])
@example Perform an upsert
Update.new('xgen', 'users', {:name => 'Tyler'}, :flags => [:upsert])
@param database [String, Symbol] The database to update. @param collection [String, Symbol] The collection to update. @param selector [Hash] The update selector. @param update [Hash] The update to perform. @param options [Hash] The additional query options.
@option options :flags [Array] The flags for the update message.
Supported flags: +:upsert+, +:multi_update+