Class: Mongoid::Persistence::Operations::Embedded::Remove
- Inherits:
-
Object
- Object
- Mongoid::Persistence::Operations::Embedded::Remove
- Defined in:
- lib/mongoid/persistence/operations/embedded/remove.rb
Overview
Remove is a persistence command responsible for deleting a document from the database.
The underlying query resembles the following MongoDB query:
collection.remove(
{ "_id" : 1 },
false
);
Instance Attribute Summary
Attributes included from Mongoid::Persistence::Operations
#conflicts, #document, #options
Instance Method Summary collapse
-
#persist ⇒ true
Remove the document from the database.
Methods included from Atomic::Positionable
Methods included from Mongoid::Persistence::Operations
#collection, #deletes, #initialize, insert, #inserts, #notifying_parent?, #parent, remove, #selector, update, #updates, upsert, #validating?
Methods included from Deletion
Instance Method Details
#persist ⇒ true
Remove the document from the database. If the parent is a new record, it will get removed in Ruby only. If the parent is not a new record then either an $unset or $set will occur, depending if it’s an embeds_one or embeds_many.
30 31 32 33 34 35 36 37 38 |
# File 'lib/mongoid/persistence/operations/embedded/remove.rb', line 30 def persist prepare do |doc| parent.remove_child(doc) if if parent.persisted? selector = parent.atomic_selector collection.find(selector).update(positionally(selector, deletes)) end end end |