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',
  collation: 'collation'
).freeze

Instance Method Summary collapse

Constructor Details

#initialize(view, session) ⇒ FindCommand

Create the find command builder.

Examples:

Create the find command builder.

FindCommandBuilder.new(view)

Parameters:

Since:

  • 2.2.2



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

def initialize(view, session)
  @view = view
  @session = session
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



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

def explain_specification
  { selector: { explain: find_command }, db_name: database.name, read: read, session: @session }
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



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

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