Class: Mongo::Collection::View::Builder::FindCommand

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/mongo/collection/view/builder/find_command.rb

Overview

Builds a find command specification from options.

Since:

  • 2.2.0

Constant Summary

MAPPINGS =

The mappings from ruby options to the find command.

Since:

  • 2.2.0

BSON::Document.new(
  sort: 'sort',
  projection: 'projection',
  hint: 'hint',
  skip: 'skip',
  limit: 'limit',
  batch_size: 'batchSize',
  single_batch: 'singleBatch',
  comment: 'comment',
  max_scan: 'maxScan',
  max_time_ms: 'maxTimeMS',
  max_value: 'max',
  min_value: 'min',
  return_key: 'returnKey',
  show_disk_loc: 'showRecordId',
  snapshot: 'snapshot',
  tailable: 'tailable',
  tailable_cursor: 'tailable',
  oplog_replay: 'oplogReplay',
  no_cursor_timeout: 'noCursorTimeout',
  await_data: 'awaitData',
  allow_partial_results: 'allowPartialResults',
  read_concern: 'readConcern',
  collation: 'collation'
).freeze

Instance Method Summary collapse

Constructor Details

#initialize(view) ⇒ FindCommand

Create the find command builder.

Examples:

Create the find command builder.

FindCommandBuilder.new(view)

Parameters:

Since:

  • 2.2.2



78
79
80
# File 'lib/mongo/collection/view/builder/find_command.rb', line 78

def initialize(view)
  @view = view
end

Instance Method Details

#explain_specificationHash

Get the specification for an explain command that wraps the find command.

Examples:

Get the explain spec.

builder.explain_specification

Returns:

  • (Hash)

    The specification.

Since:

  • 2.2.0



66
67
68
# File 'lib/mongo/collection/view/builder/find_command.rb', line 66

def explain_specification
  { selector: { explain: find_command }, db_name: database.name, read: read }
end

#specificationHash

Get the specification to pass to the find command operation.

Examples:

Get the specification.

builder.specification

Returns:

  • (Hash)

    The specification.

Since:

  • 2.2.0



90
91
92
# File 'lib/mongo/collection/view/builder/find_command.rb', line 90

def specification
  { selector: find_command, db_name: database.name, read: read }
end