Sha256: 5609f1ede3b4a0fa4093cf99b3f169f492eb36b5604f372bbf1f1b46da484e06

Contents?: true

Size: 645 Bytes

Versions: 13

Compression:

Stored size: 645 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 = {})
        collection = klass.collection
        collection.remove((params[:conditions] || {}).merge(:_type => klass.name))
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
mongoid-pre-2.0.0.pre lib/mongoid/commands/delete_all.rb
mongoid-1.2.6 lib/mongoid/commands/delete_all.rb
mongoid-1.2.5 lib/mongoid/commands/delete_all.rb
mongoid-1.2.4 lib/mongoid/commands/delete_all.rb
mongoid-1.2.3 lib/mongoid/commands/delete_all.rb
mongoid-1.2.2 lib/mongoid/commands/delete_all.rb
mongoid-1.2.1 lib/mongoid/commands/delete_all.rb
mongoid-1.2.0 lib/mongoid/commands/delete_all.rb
mongoid-1.1.4 lib/mongoid/commands/delete_all.rb
mongoid-1.1.3 lib/mongoid/commands/delete_all.rb
mongoid-1.1.2 lib/mongoid/commands/delete_all.rb
mongoid-1.1.1 lib/mongoid/commands/delete_all.rb
mongoid-1.1.0 lib/mongoid/commands/delete_all.rb