Object
Insert is a persistence command responsible for taking a document that has not been saved to the database and saving it. This specific class handles the case when the document is embedded in another.
The underlying query resembles the following MongoDB query:
collection.update( { "_id" : 1 }, { "$push" : { "field" : "value" } }, false );
Insert the new document in the database. If the document’s parent is a new record, we will call save on the parent, otherwise we will $push the document onto the parent.
@example Insert an embedded document.
Insert.persist
@return [ Document ] The document to be inserted.
# File lib/mongoid/persistence/operations/embedded/insert.rb, line 28 def persist prepare do if parent.new? parent.insert else collection.update(parent.atomic_selector, inserts, options) end end end
Generated with the Darkfish Rdoc Generator 2.