Class: Mongo::Protocol::Update
- Defined in:
- build/ruby-driver-v2.17/lib/mongo/protocol/update.rb
Overview
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.
Defined Under Namespace
Classes: Upconverter
Constant Summary
Constants inherited from Message
Message::BATCH_SIZE, Message::COLLECTION, Message::LIMIT, Message::MAX_MESSAGE_SIZE, Message::ORDERED, Message::Q
Instance Attribute Summary
Attributes inherited from Message
Instance Method Summary collapse
-
#initialize(database, collection, selector, update, options = {}) ⇒ Update
constructor
Creates a new Update message.
-
#payload ⇒ BSON::Document
Return the event payload for monitoring.
Methods inherited from Message
#==, deserialize, #hash, #maybe_add_server_api, #maybe_compress, #maybe_decrypt, #maybe_encrypt, #maybe_inflate, #number_returned, #replyable?, #serialize, #set_request_id
Methods included from Id
Constructor Details
#initialize(database, collection, selector, update, options = {}) ⇒ Update
Creates a new Update message
57 58 59 60 61 62 63 64 65 66 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 57 def initialize(database, collection, selector, update, = {}) @database = database @collection = collection @namespace = "#{database}.#{collection}" @selector = selector @update = update @flags = [:flags] || [] @upconverter = Upconverter.new(collection, selector, update, flags) super end |
Instance Method Details
#payload ⇒ BSON::Document
Return the event payload for monitoring.
76 77 78 79 80 81 82 83 |
# File 'build/ruby-driver-v2.17/lib/mongo/protocol/update.rb', line 76 def payload BSON::Document.new( command_name: 'update', database_name: @database, command: upconverter.command, request_id: request_id ) end |