Class: Mongoid::Persistence::Operations::Remove

Inherits:
Object
  • Object
show all
Includes:
Deletion, Mongoid::Persistence::Operations
Defined in:
lib/mongoid/persistence/operations/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

Instance Method Summary collapse

Methods included from Deletion

#prepare

Methods included from Mongoid::Persistence::Operations

#collection, #deletes, #initialize, insert, #inserts, #notifying_parent?, #options, #parent, remove, #selector, update, #updates, #validating?

Instance Method Details

#persisttrue

Remove the document from the database: delegates to the MongoDB collection remove method.

Examples:

Remove the document.

Remove.persist

Returns:

  • (true)

    Always true.



25
26
27
28
29
# File 'lib/mongoid/persistence/operations/remove.rb', line 25

def persist
  prepare do |doc|
    collection.remove({ :_id => doc.id }, options)
  end
end