class Mongo::Protocol::Delete::Upconverter
Converts legacy delete messages to the appropriare OP_COMMAND style message.
@since 2.1.0
Constants
- DELETE
-
The delete command constant.
@since 2.2.0
- DELETES
-
The deletes command constant.
@since 2.2.0
Attributes
@return [ String ] collection The name of the collection.
@return [ BSON::Document, Hash ] filter The query filter or command.
@return [ Hash ] options The options.
Public Class Methods
Source
# File lib/mongo/protocol/delete.rb, line 133 def initialize(collection, filter, options) @collection = collection @filter = filter @options = options end
Instantiate the upconverter.
@example Instantiate the upconverter.
Upconverter.new('users', { name: 'test' })
@param [ String ] collection The name of the collection. @param [ BSON::Document, Hash ] filter The filter or command.
@since 2.1.0
Public Instance Methods
Source
# File lib/mongo/protocol/delete.rb, line 147 def command document = BSON::Document.new document.store(DELETE, collection) document.store(DELETES, [ BSON::Document.new(Message::Q => filter, Message::LIMIT => limit) ]) document.store(Message::ORDERED, true) document end
Get the upconverted command.
@example Get the command.
upconverter.command
@return [ BSON::Document ] The upconverted command.
@since 2.1.0
Private Instance Methods
Source
# File lib/mongo/protocol/delete.rb, line 157 def limit if options.key?(:flags) options[:flags].include?(:single_remove) ? 1 : 0 else 0 end end