Parent

Methods

Class/Module Index [+]

Quicksearch

Mongoid::Persistence::Operations::Insert

Insert is a persistence command responsible for taking a document that has not been saved to the database and saving it.

The underlying query resembles the following MongoDB query:

collection.insert(
  { "_id" : 1, "field" : "value" },
  false
);

Public Instance Methods

persist() click to toggle source

Insert the new document in the database. This delegates to the standard MongoDB collection's insert command.

@example Insert the document.

Insert.persist

@return [ Document ] The document to be inserted.

# File lib/mongoid/persistence/operations/insert.rb, line 24
def persist
  prepare do |doc|
    collection.insert(doc.as_document)
    IdentityMap.set(doc)
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.