lib/mongoid/contextual/mongo.rb in mongoid-6.0.3 vs lib/mongoid/contextual/mongo.rb in mongoid-6.1.0.rc0

- old
+ new

@@ -16,11 +16,23 @@ include Queryable # Options constant. # # @since 5.0.0 - OPTIONS = [ :hint, :limit, :skip, :sort, :batch_size, :max_scan, :max_time_ms, :snapshot, :comment, :read ].freeze + OPTIONS = [ :hint, + :limit, + :skip, + :sort, + :batch_size, + :max_scan, + :max_time_ms, + :snapshot, + :comment, + :read, + :cursor_type, + :collation + ].freeze # @attribute [r] view The Mongo collection view. attr_reader :view # Is the context cached? @@ -66,13 +78,11 @@ # # @return [ nil ] Nil. # # @since 3.0.0 def delete - self.count.tap do - view.delete_many - end + view.delete_many.deleted_count end alias :delete_all :delete # Destroy all documents in the database that match the selector. # @@ -81,15 +91,14 @@ # # @return [ nil ] Nil. # # @since 3.0.0 def destroy - destroyed = self.count - each do |doc| + each.inject(0) do |count, doc| doc.destroy + count += 1 end - destroyed end alias :destroy_all :destroy # Get the distinct values in the db for the provided field. # @@ -565,15 +574,9 @@ OPTIONS.each do |name| apply_option(name) end if criteria.options[:timeout] == false @view = view.no_cursor_timeout - end - if criteria.options[:cursor_type] - # @todo: update to use #cursor_type method on view when driver 2.3 is released. - # See RUBY-1080 - @view = view.clone - @view.options.merge!(cursor_type: criteria.options[:cursor_type]) end end # Apply an option. #