123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Persistable::Deletable::ClassMethods

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Defined in: lib/mongoid/persistable/deletable.rb

Instance Method Summary

Instance Method Details

#delete_all(conditions = {}) ⇒ Integer

Delete all documents given the supplied conditions. If no conditions are passed, the entire collection will be dropped for performance benefits. Does not fire any callbacks.

Examples:

Delete matching documents from the collection.

Person.delete_all({ :title => "Sir" })

Delete all documents from the collection.

Person.delete_all

Parameters:

  • conditions (Hash) (defaults to: {})

    Optional conditions to delete by.

Returns:

  • (Integer)

    The number of documents deleted.

[ GitHub ]

  
# File 'lib/mongoid/persistable/deletable.rb', line 130

def delete_all(conditions = {})
  selector = hereditary? ? conditions.merge(discriminator_key.to_sym => discriminator_value) : conditions
  where(selector).delete
end