Sha256: 8374beb1f9c5f44f6d29c618027604b0a4551fd0267874e089628784dcfe5998
Contents?: true
Size: 798 Bytes
Versions: 1
Compression:
Stored size: 798 Bytes
Contents
# encoding: utf-8 module Mongoid #:nodoc: module Commands class DeleteAll # 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: # # <tt>DeleteAll.execute(Person, :conditions => { :field => "value" })</tt> def self.execute(klass, params = {}) safe = Mongoid.persist_in_safe_mode collection = klass.collection selector = (params[:conditions] || {}).merge(:_type => klass.name) matching = collection.find(selector).count collection.remove(selector, :safe => safe) ? matching : 0 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-pre-2.0.0.beta1 | lib/mongoid/commands/delete_all.rb |