Module: Mongo::Collection::View::Builder::Modifiers

Extended by:
Modifiers
Included in:
Modifiers
Defined in:
lib/mongo/collection/view/builder/modifiers.rb

Overview

Provides behaviour for mapping modifiers.

Since:

  • 2.2.0

Constant Summary

DRIVER_MAPPINGS =

Mappings from driver options to legacy server values.

Since:

  • 2.2.0

BSON::Document.new(
  sort: '$orderby',
  hint: '$hint',
  comment: '$comment',
  snapshot: '$snapshot',
  max_scan: '$maxScan',
  max_value: '$max',
  min_value: '$min',
  max_time_ms: '$maxTimeMS',
  return_key: '$returnKey',
  show_disk_loc: '$showDiskLoc',
  explain: '$explain'
).freeze
SERVER_MAPPINGS =

Mappings from server values to driver options.

Since:

  • 2.2.0

BSON::Document.new(DRIVER_MAPPINGS.invert).freeze

Class Method Summary collapse

Class Method Details

.map_driver_options(modifiers) ⇒ BSON::Document

Transform the provided server modifiers to driver options.

Examples:

Transform to driver options.

Modifiers.map_driver_options(modifiers)

Parameters:

  • modifiers (Hash)

    The modifiers.

Returns:

  • (BSON::Document)

    The driver options.

Since:

  • 2.2.0



58
59
60
# File 'lib/mongo/collection/view/builder/modifiers.rb', line 58

def self.map_driver_options(modifiers)
  Options::Mapper.transform_documents(modifiers, SERVER_MAPPINGS)
end

.map_server_modifiers(options) ⇒ BSON::Document

Transform the provided options into a document of only server modifiers.

Examples:

Map the server modifiers.

Modifiers.map_server_modifiers(options)

Parameters:

  • options (Hash, BSON::Document)

    The options.

Returns:

  • (BSON::Document)

    The modifiers.

Since:

  • 2.2.0



73
74
75
# File 'lib/mongo/collection/view/builder/modifiers.rb', line 73

def self.map_server_modifiers(options)
  Options::Mapper.transform_documents(options, DRIVER_MAPPINGS)
end