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 behaviour around an aggregation pipeline on a collection view.
Constant Summary collapse
- REROUTE =
The reroute message.
'Rerouting the Aggregation operation to the primary server.'.freeze
Constants included from Retryable
Retryable::COULD_NOT_CONTACT_PRIMARY, Retryable::NOT_MASTER
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
#read_with_retry, #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.
73 74 75 76 77 |
# File 'lib/mongo/collection/view/aggregation.rb', line 73 def initialize(view, pipeline, = {}) @view = view @pipeline = pipeline.dup @options = .dup 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.
58 59 60 |
# File 'lib/mongo/collection/view/aggregation.rb', line 58 def allow_disk_use(value = nil) configure(:allow_disk_use, value) end |
#explain ⇒ Hash
Get the explain plan for the aggregation.
87 88 89 |
# File 'lib/mongo/collection/view/aggregation.rb', line 87 def explain self.class.new(view, pipeline, .merge(explain: true)).first end |