class Mongo::Protocol::Insert::Upconverter
Converts legacy insert messages to the appropriare OP_COMMAND style message.
@since 2.1.0
Constants
- DOCUMENTS
-
Documents field constant.
@since 2.1.0
- INSERT
-
Insert
field constant.@since 2.1.0
- WRITE_CONCERN
-
Write concern field constant.
@since 2.1.0
Attributes
@return [ String ] collection The name of the collection.
@return [ Array<BSON::Document> ] documents The documents to insert.
@return [ Hash ] options The options.
Public Class Methods
Source
# File lib/mongo/protocol/insert.rb, line 151 def initialize(collection, documents, options) @collection = collection @documents = documents @options = options end
Instantiate the upconverter.
@example Instantiate the upconverter.
Upconverter.new('users', documents)
@param [ String ] collection The name of the collection. @param [ Array<BSON::Document> ] documents The documents. @param [ Hash ] options The options.
@since 2.1.0
Public Instance Methods
Source
# File lib/mongo/protocol/insert.rb, line 165 def command document = BSON::Document.new document.store(INSERT, collection) document.store(DOCUMENTS, documents) document.store(Message::ORDERED, options.fetch(:ordered, true)) document.merge!(WRITE_CONCERN => options[:write_concern].options) if options[:write_concern] document end
Get the upconverted command.
@example Get the command.
upconverter.command
@return [ BSON::Document ] The upconverted command.
@since 2.1.0