Class: Mongo::Collection::View::Builder::Aggregation
- Inherits:
-
Object
- Object
- Mongo::Collection::View::Builder::Aggregation
- Extended by:
- Forwardable
- Defined in:
- lib/mongo/collection/view/builder/aggregation.rb
Overview
Builds an aggregation command specification from the view and options.
Constant Summary collapse
- MAPPINGS =
The mappings from ruby options to the aggregation options.
BSON::Document.new( allow_disk_use: 'allowDiskUse', bypass_document_validation: 'bypassDocumentValidation', explain: 'explain', collation: 'collation', comment: 'comment', hint: 'hint', let: 'let', # This is intentional; max_await_time_ms is an alias for maxTimeMS # used on getMore commands for change streams. max_await_time_ms: 'maxTimeMS', max_time_ms: 'maxTimeMS', ).freeze
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Options The map/reduce specific options.
-
#pipeline ⇒ Array<Hash>
readonly
Pipeline The pipeline.
-
#view ⇒ Collection::View
readonly
View The collection view.
Instance Method Summary collapse
-
#initialize(pipeline, view, options) ⇒ Aggregation
constructor
Initialize the builder.
-
#specification ⇒ Hash
Get the specification to pass to the aggregation operation.
Constructor Details
#initialize(pipeline, view, options) ⇒ Aggregation
Initialize the builder.
64 65 66 67 68 |
# File 'lib/mongo/collection/view/builder/aggregation.rb', line 64 def initialize(pipeline, view, ) @pipeline = pipeline @view = view @options = end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns options The map/reduce specific options.
55 56 57 |
# File 'lib/mongo/collection/view/builder/aggregation.rb', line 55 def @options end |
#pipeline ⇒ Array<Hash> (readonly)
Returns pipeline The pipeline.
49 50 51 |
# File 'lib/mongo/collection/view/builder/aggregation.rb', line 49 def pipeline @pipeline end |
#view ⇒ Collection::View (readonly)
Returns view The collection view.
52 53 54 |
# File 'lib/mongo/collection/view/builder/aggregation.rb', line 52 def view @view end |
Instance Method Details
#specification ⇒ Hash
Get the specification to pass to the aggregation operation.
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/mongo/collection/view/builder/aggregation.rb', line 78 def specification spec = { selector: aggregation_command, db_name: database.name, read: @options[:read_preference] || view.read_preference, session: @options[:session], collation: @options[:collation], } if write? spec.update(write_concern: write_concern) end spec end |