The Protocol class for inserting documents into a collection.
@example
insert = Insert.new "moped", "people", [{ name: "John" }]
@example Continuing after an error on batch insert
insert = Insert.new "moped", "people", [{ unique_field: 1 }, { unique_field: 1 }, { unique_field: 2 }], flags: [:continue_on_error]
@example Setting the request id
insert = Insert.new "moped", "people", [{ name: "John" }], request_id: 123
Create a new insert command. The database and collection arguments are joined together to set the full_collection_name.
@example
Insert.new "moped", "users", [{ name: "John" }], flags: [:continue_on_error], request_id: 123
@param [String, Symbol] database the database to insert into @param [String, Symbol] collection the collection to insert into @param [Array<Hash>] documents the documents to insert @param [Hash] options additional options @option options [Number] :request_id the command's request id @option options [Array] :flags the flags for insertion. Supported
flags: +:continue_on_error+
# 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
Generated with the Darkfish Rdoc Generator 2.