Class Mongo::Protocol::Query::Upconverter
In: lib/mongo/protocol/query.rb
Parent: Object

Converts legacy query messages to the appropriare OP_COMMAND style message.

@since 2.1.0

Methods

command   command_name   new  

Constants

OPTION_MAPPINGS = { :project => 'projection', :skip => 'skip', :limit => 'limit', :batch_size => 'batchSize'   Mappings of the options to the find command options.

@since 2.1.0

SPECIAL_FIELD_MAPPINGS = { :$readPreference => 'readPreference', :$orderby => 'sort', :$hint => 'hint', :$comment => 'comment', :$returnKey => 'returnKey', :$snapshot => 'snapshot', :$maxScan => 'maxScan', :$max => 'max', :$min => 'min', :$maxTimeMS => 'maxTimeMS', :$showDiskLoc => 'showRecordId', :$explain => 'explain'
FLAG_MAPPINGS = { :tailable_cursor => 'tailable', :oplog_replay => 'oplogReplay', :no_cursor_timeout => 'noCursorTimeout', :await_data => 'awaitData', :partial => 'allowPartialResults'   Mapping of flags to find command options.

@since 2.1.0

FIND = 'find'.freeze   Find command constant.

@since 2.1.0

FILTER = 'filter'.freeze   Filter attribute constant.

@since 2.1.0

Attributes

collection  [R]  @return [ String ] collection The name of the collection.
filter  [R]  @return [ BSON::Document, Hash ] filter The query filter or command.
flags  [R]  @return [ Array<Symbol> ] flags The flags.
options  [R]  @return [ BSON::Document, Hash ] options The options.

Public Class methods

Instantiate the upconverter.

@example Instantiate the upconverter.

  Upconverter.new('users', { name: 'test' }, { skip: 10 })

@param [ String ] collection The name of the collection. @param [ BSON::Document, Hash ] filter The filter or command. @param [ BSON::Document, Hash ] options The options. @param [ Array<Symbol> ] flags The flags.

@since 2.1.0

Public Instance methods

Get the upconverted command.

@example Get the command.

  upconverter.command

@return [ BSON::Document ] The upconverted command.

@since 2.1.0

Get the name of the command. If the collection is $cmd then it‘s the first key in the filter, otherwise it‘s a find.

@example Get the command name.

  upconverter.command_name

@return [ String ] The command name.

@since 2.1.0

[Validate]