Class: Mongo::Collection::View::Aggregation
- Inherits:
-
Object
- Object
- Mongo::Collection::View::Aggregation
- Extended by:
- Forwardable
- Includes:
- Enumerable, Explainable, Immutable, Iterable, Loggable, Retryable
- Defined in:
- lib/mongo/collection/view/aggregation.rb
Overview
Provides behavior around an aggregation pipeline on a collection view.
Direct Known Subclasses
Constant Summary collapse
- REROUTE =
Deprecated.
The reroute message.
'Rerouting the Aggregation operation to the primary server.'.freeze
Constants included from Loggable
Constants included from Explainable
Explainable::ALL_PLANS_EXECUTION, Explainable::EXECUTION_STATS, Explainable::QUERY_PLANNER
Instance Attribute Summary collapse
-
#pipeline ⇒ Array<Hash>
readonly
Pipeline The aggregation pipeline.
-
#view ⇒ View
readonly
View The collection view.
Attributes included from Immutable
Instance Method Summary collapse
-
#allow_disk_use(value = nil) ⇒ true, ...
Set to true if disk usage is allowed during the aggregation.
-
#explain ⇒ Hash
Get the explain plan for the aggregation.
-
#initialize(view, pipeline, options = {}) ⇒ Aggregation
constructor
Initialize the aggregation for the provided collection view, pipeline and options.
Methods included from Retryable
#legacy_write_with_retry, #nro_write_with_retry, #read_with_one_retry, #read_with_retry, #read_with_retry_cursor, #write_with_retry
Methods included from Loggable
#log_debug, #log_error, #log_fatal, #log_info, #log_warn, #logger
Methods included from Iterable
Constructor Details
#initialize(view, pipeline, options = {}) ⇒ Aggregation
Initialize the aggregation for the provided collection view, pipeline and options.
74 75 76 77 78 |
# File 'lib/mongo/collection/view/aggregation.rb', line 74 def initialize(view, pipeline, = {}) @view = view @pipeline = pipeline.dup @options = BSON::Document.new().freeze end |
Instance Attribute Details
#pipeline ⇒ Array<Hash> (readonly)
Returns pipeline The aggregation pipeline.
34 35 36 |
# File 'lib/mongo/collection/view/aggregation.rb', line 34 def pipeline @pipeline end |
#view ⇒ View (readonly)
Returns view The collection view.
32 33 34 |
# File 'lib/mongo/collection/view/aggregation.rb', line 32 def view @view end |
Instance Method Details
#allow_disk_use(value = nil) ⇒ true, ...
Set to true if disk usage is allowed during the aggregation.
59 60 61 |
# File 'lib/mongo/collection/view/aggregation.rb', line 59 def allow_disk_use(value = nil) configure(:allow_disk_use, value) end |
#explain ⇒ Hash
Get the explain plan for the aggregation.
88 89 90 |
# File 'lib/mongo/collection/view/aggregation.rb', line 88 def explain self.class.new(view, pipeline, .merge(explain: true)).first end |