class Mongo::Operation::Write::Command::Insert
A MongoDB insert write command operation.
@example Create an insert write command operation.
Write::Command::Insert.new({ :documents => [{ :foo => 1 }], :db_name => 'test', :coll_name => 'test_coll', :write_concern => write_concern, :ordered => true })
@since 2.0.0
Constants
- IDENTIFIER
Private Instance Methods
message(server)
click to toggle source
# File lib/mongo/operation/write/command/insert.rb, line 56 def message(server) if server.features.op_msg_enabled? op_msg(server) else opts = options.merge(validating_keys: true) Protocol::Query.new(db_name, Database::COMMAND, selector, opts) end end
op_msg(server)
click to toggle source
# File lib/mongo/operation/write/command/insert.rb, line 45 def op_msg(server) global_args = { insert: coll_name, Protocol::Msg::DATABASE_IDENTIFIER => db_name }.merge!(command_options) update_selector_for_session!(global_args, server) section = { type: 1, payload: { identifier: IDENTIFIER, sequence: documents } } flags = unacknowledged_write? ? [:more_to_come] : [:none] Protocol::Msg.new(flags, { validating_keys: true }, global_args, section) end
selector()
click to toggle source
# File lib/mongo/operation/write/command/insert.rb, line 39 def selector { insert: coll_name, documents: documents }.merge!(command_options) end