Method: Moped::Protocol::Insert#initialize

Defined in:
lib/moped/protocol/insert.rb

#initialize(database, collection, documents, options = {}) ⇒ Insert

Create a new insert command. The database and collection arguments are joined together to set the full_collection_name.

Examples:

Insert.new "moped", "users", [{ name: "John" }],
  flags: [:continue_on_error],
  request_id: 123

Parameters:

  • database (String, Symbol)

    the database to insert into

  • collection (String, Symbol)

    the collection to insert into

  • documents (Array<Hash>)

    the documents to insert

  • options (Hash) (defaults to: {})

    additional options

Options Hash (options):

  • :request_id (Number)

    the command’s request id

  • :flags (Array)

    the flags for insertion. Supported flags: :continue_on_error



78
79
80
81
82
83
84
85
86
# File 'lib/moped/protocol/insert.rb', line 78

def initialize(database, collection, documents, options = {})
  @database = database
  @collection = collection

  @full_collection_name = "#{database}.#{collection}"
  @documents            = documents
  @request_id           = options[:request_id]
  @flags                = options[:flags]
end