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

Private Instance Methods

selector() click to toggle source

The query selector for this insert command operation.

@return [ Hash ] The selector describing this insert operation.

@since 2.0.0

# File lib/mongo/operation/write/command/insert.rb, line 42
def selector
  { insert: coll_name,
    documents: documents,
    ordered: ordered?
  }.tap do |cmd|
    cmd.merge!(writeConcern: write_concern.options) if write_concern
    cmd.merge!(:bypassDocumentValidation => true) if bypass_document_validation
  end
end