Class: Mongoid::Commands::DeleteAll
- Defined in:
- lib/mongoid/commands/delete_all.rb
Class Method Summary collapse
-
.execute(klass, params = nil) ⇒ Object
Performs a delete of the all the
Documents
that match the criteria supplied.
Class Method Details
.execute(klass, params = nil) ⇒ Object
Performs a delete of the all the Documents
that match the criteria supplied.
Options:
params: A set of conditions to find the Documents
by. klass: The class of the Document
to execute the find on.
Example:
DeleteAll.execute(Person, :conditions => { :field => "value" })
16 17 18 19 20 |
# File 'lib/mongoid/commands/delete_all.rb', line 16 def self.execute(klass, params = nil) params ? klass.find(:all, params).each do |doc| Delete.execute(doc) end : klass.collection.drop end |