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
16 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 16 attr_writer :aggregating |
#aggregating=(value) ⇒ Object (writeonly)
Sets the attribute aggregating
16 17 18 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 16 def aggregating=(value) @aggregating = value end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
13 14 15 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 13 def pipeline @pipeline end |
#pipeline The aggregation pipeline.(Theaggregationpipeline.) ⇒ Object (readonly)
13 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 13 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.
25 26 27 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 25 def aggregating? !!@aggregating end |
#group(operation) ⇒ Aggregable
Add a group ($group) operation to the aggregation pipeline.
40 41 42 43 44 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 40 def group(operation) aggregation(operation) do |pipeline| pipeline.group(operation) end end |
#project(operation = nil) ⇒ Aggregable
Add a projection ($project) to the aggregation pipeline.
62 63 64 65 66 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 62 def project(operation = nil) aggregation(operation) do |pipeline| pipeline.project(operation) end end |
#unwind(field) ⇒ Aggregable
Add an unwind ($unwind) to the aggregation pipeline.
76 77 78 79 80 |
# File 'lib/mongoid/criteria/queryable/aggregable.rb', line 76 def unwind(field) aggregation(field) do |pipeline| pipeline.unwind(field) end end |