Class: Daodalus::DSL::Aggregation::Group
Defined Under Namespace
Classes: Alias
Instance Method Summary
collapse
#aggregate, #group, #limit, #match, #pipeline, #project, #skip, #sort, #unwind
Constructor Details
#initialize(dao, aggregations, id, values) ⇒ Group
Returns a new instance of Group.
7
8
9
10
11
12
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 7
def initialize(dao, aggregations, id, values)
@dao = dao
@aggregations = aggregations
@id = id
@values = values
end
|
Instance Method Details
#add_to_set(field) ⇒ Object
Also known as:
distinct
23
24
25
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 23
def add_to_set(field)
aliased '$addToSet' => field
end
|
#avg(field) ⇒ Object
Also known as:
average
49
50
51
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 49
def avg(field)
aliased '$avg' => field
end
|
#first(field) ⇒ Object
33
34
35
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 33
def first(field)
aliased '$first' => field
end
|
#last(field) ⇒ Object
37
38
39
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 37
def last(field)
aliased '$last' => field
end
|
#max(field) ⇒ Object
41
42
43
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 41
def max(field)
aliased '$max' => field
end
|
#min(field) ⇒ Object
45
46
47
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 45
def min(field)
aliased '$min' => field
end
|
#push(field) ⇒ Object
Also known as:
collect
28
29
30
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 28
def push(field)
aliased '$push' => field
end
|
#sum(field) ⇒ Object
Also known as:
total
18
19
20
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 18
def sum(field)
aliased '$sum' => field
end
|
#to_aggregation ⇒ Object
14
15
16
|
# File 'lib/daodalus/dsl/aggregation/group.rb', line 14
def to_aggregation
{ '$group' => values.merge('_id' => id) }
end
|