Class: Mongoid::Persistence::Operations::Embedded::Remove
- Includes:
- Deletion, Mongoid::Persistence::Operations
- 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
Instance Method Summary collapse
-
#persist ⇒ true
Remove the document from the database.
Methods included from Deletion
Methods included from Mongoid::Persistence::Operations
#collection, #deletes, #initialize, insert, #inserts, #notifying_parent?, #options, #parent, remove, #selector, update, #updates, #validating?
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.
28 29 30 31 32 33 34 35 |
# File 'lib/mongoid/persistence/operations/embedded/remove.rb', line 28 def persist prepare do |doc| parent.remove_child(doc) if if parent.persisted? collection.update(parent.atomic_selector, deletes, ) end end end |