# encoding: utf-8 module Mongoid #:nodoc: module Persistence #:nodoc: # Remove is a persistence command responsible for deleting a document from # the database. # # The underlying query resembles the following MongoDB query: # # collection.remove( # { "field" : value }, # false # ); class RemoveAll < Command # Remove the document from the database: delegates to the MongoDB # collection remove method. # # Example: # # Remove.persist # # Returns: # # +true+ if success, +false+ if not. def persist remove end protected # Remove the document from the database. def remove count = @collection.find(@selector.merge(:_type => @klass.name)).count @collection.remove(@selector, @options) count end end end end