Sha256: 5baa56508ea70835ab2330d5d7fcae1d206ef87aedcf81e096307da40c9ad55f

Contents?: true

Size: 669 Bytes

Versions: 18

Compression:

Stored size: 669 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
        params.any? ? collection.remove(params[:conditions].merge(:_type => klass.name)) : collection.drop
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
mongoid-1.0.6 lib/mongoid/commands/delete_all.rb
mongoid-1.0.5 lib/mongoid/commands/delete_all.rb
mongoid-1.0.4 lib/mongoid/commands/delete_all.rb
mongoid-1.0.3 lib/mongoid/commands/delete_all.rb
mongoid-1.0.2 lib/mongoid/commands/delete_all.rb
mongoid-1.0.1 lib/mongoid/commands/delete_all.rb
mongoid-1.0.0 lib/mongoid/commands/delete_all.rb
mongoid-0.12.0 lib/mongoid/commands/delete_all.rb
mongoid-0.11.9 lib/mongoid/commands/delete_all.rb
mongoid-0.11.8 lib/mongoid/commands/delete_all.rb
mongoid-0.11.7 lib/mongoid/commands/delete_all.rb
mongoid-0.11.6 lib/mongoid/commands/delete_all.rb
mongoid-0.11.5 lib/mongoid/commands/delete_all.rb
mongoid-0.11.4 lib/mongoid/commands/delete_all.rb
mongoid-0.11.3 lib/mongoid/commands/delete_all.rb
mongoid-0.11.2 lib/mongoid/commands/delete_all.rb
mongoid-0.11.1 lib/mongoid/commands/delete_all.rb
mongoid-0.11.0 lib/mongoid/commands/delete_all.rb