Method: Mongo::Operation::Find::Builder::Command.selector

Defined in:
lib/mongo/operation/find/builder/command.rb

.selector(spec, connection) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 2.0.0



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/mongo/operation/find/builder/command.rb', line 58

module_function def selector(spec, connection)
  if spec[:collation] && !connection.features.collation_enabled?
    raise Error::UnsupportedCollation
  end

  BSON::Document.new.tap do |selector|
    OPTION_MAPPINGS.each do |k, server_k|
      unless (value = spec[k]).nil?
        selector[server_k] = value
      end
    end

    if rc = selector[:readConcern]
      selector[:readConcern] = Options::Mapper.transform_values_to_strings(rc)
    end

    convert_limit_and_batch_size!(selector)
  end
end