module Mongoid::Persistable::Deletable::ClassMethods
Public Instance Methods
delete_all(conditions = {})
click to toggle source
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.
@example Delete matching documents from the collection.
Person.delete_all({ :title => "Sir" })
@example Delete all documents from the collection.
Person.delete_all
@param [ Hash ] conditions Optional conditions to delete by.
@return [ Integer ] The number of documents deleted.
@since 1.0.0
# File lib/mongoid/persistable/deletable.rb, line 142 def delete_all(conditions = {}) selector = hereditary? ? conditions.merge(discriminator_key.to_sym => discriminator_value) : conditions where(selector).delete end