Class: Mongo::Protocol::Insert
- Defined in:
- lib/mongo/protocol/insert.rb
Overview
MongoDB Wire protocol Insert message.
This is a client request message that is sent to the server in order to insert documents within a namespace.
The operation only has one flag :continue_on_error which the user can use to instruct the database server to continue processing a bulk insertion if one happens to fail (e.g. due to duplicate IDs). This makes builk insert behave similarly to a seires of single inserts, except lastError will be set if any insert fails, not just the last one.
If multiple errors occur, only the most recent will be reported by the getLastError mechanism.
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, documents, options = {}) ⇒ Insert
constructor
Creates a new Insert message.
-
#payload ⇒ BSON::Document
Return the event payload for monitoring.
Methods inherited from Message
#==, deserialize, #hash, #maybe_compress, #maybe_decrypt, #maybe_encrypt, #maybe_inflate, #number_returned, #replyable?, #serialize, #set_request_id
Methods included from Id
Constructor Details
#initialize(database, collection, documents, options = {}) ⇒ Insert
Creates a new Insert message
53 54 55 56 57 58 59 60 61 |
# File 'lib/mongo/protocol/insert.rb', line 53 def initialize(database, collection, documents, = {}) @database = database @namespace = "#{database}.#{collection}" @documents = documents @flags = [:flags] || [] @upconverter = Upconverter.new(collection, documents, ) @options = super end |
Instance Method Details
#payload ⇒ BSON::Document
Return the event payload for monitoring.
71 72 73 74 75 76 77 78 |
# File 'lib/mongo/protocol/insert.rb', line 71 def payload BSON::Document.new( command_name: 'insert', database_name: @database, command: upconverter.command, request_id: request_id ) end |