Module: Mongoid::Criteria::Queryable::Aggregable
- Extended by:
- Macroable
- Included in:
- Mongoid::Criteria::Queryable
- Defined in:
- lib/mongoid/criteria/queryable/aggregable.rb
Overview
Provides a DSL around crafting aggregation framework commands.
Instance Attribute Summary collapse
- #aggregating Flag for whether or not we are aggregating.(Flag) ⇒ Object
-
#aggregating ⇒ Object
writeonly
Sets the attribute aggregating.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
- #pipeline The aggregation pipeline.(Theaggregationpipeline.) ⇒ Object readonly
Instance Method Summary collapse
-
#aggregating? ⇒ true | false
Has the aggregable enter an aggregation state.
-
#group(operation) ⇒ Aggregable
Add a group ($group) operation to the aggregation pipeline.
-
#project(operation = nil) ⇒ Aggregable
Add a projection ($project) to the aggregation pipeline.
-
#unwind(field) ⇒ Aggregable
Add an unwind ($unwind) to the aggregation pipeline.
Methods included from Macroable
Instance Attribute Details
#aggregating Flag for whether or not we are aggregating.(Flag) ⇒ Object
14 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 14 attr_writer :aggregating |
#aggregating=(value) ⇒ Object (writeonly)
Sets the attribute aggregating
14 15 16 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 14 def aggregating=(value) @aggregating = value end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
11 12 13 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 11 def pipeline @pipeline end |
#pipeline The aggregation pipeline.(Theaggregationpipeline.) ⇒ Object (readonly)
11 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 11 attr_reader :pipeline |
Instance Method Details
#aggregating? ⇒ true | false
Has the aggregable enter an aggregation state. Ie, are only aggregation operations allowed at this point on.
23 24 25 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 23 def aggregating? !!@aggregating end |
#group(operation) ⇒ Aggregable
Add a group ($group) operation to the aggregation pipeline.
38 39 40 41 42 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 38 def group(operation) aggregation(operation) do |pipeline| pipeline.group(operation) end end |
#project(operation = nil) ⇒ Aggregable
Add a projection ($project) to the aggregation pipeline.
60 61 62 63 64 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 60 def project(operation = nil) aggregation(operation) do |pipeline| pipeline.project(operation) end end |
#unwind(field) ⇒ Aggregable
Add an unwind ($unwind) to the aggregation pipeline.
74 75 76 77 78 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 74 def unwind(field) aggregation(field) do |pipeline| pipeline.unwind(field) end end |