Class: Daodalus::DSL::Aggregation::Project
Instance Method Summary
collapse
#aggregate, #group, #limit, #match, #pipeline, #skip, #sort, #unwind
Constructor Details
#initialize(dao, aggregations, projection = {}, keys) ⇒ Project
Returns a new instance of Project.
7
8
9
10
11
12
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 7
def initialize(dao, aggregations, projection = {}, keys)
@dao = dao
@aggregations = aggregations
@projection = projection
@keys = keys
end
|
Instance Method Details
#add(*others) ⇒ Object
Also known as:
plus
31
32
33
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 31
def add(*others)
Project.new(dao, aggregations, @projection, ['$add' => keys + others])
end
|
#as(aka) ⇒ Object
23
24
25
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 23
def as(aka)
Project.new(dao, aggregations, @projection, [aka => keys.first])
end
|
#divide(other) ⇒ Object
Also known as:
divided_by
36
37
38
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 36
def divide(other)
Project.new(dao, aggregations, @projection, ['$divide' => keys + [other]])
end
|
#eq(*others) ⇒ Object
27
28
29
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 27
def eq(*others)
Project.new(dao, aggregations, @projection, ['$eq' => keys + others])
end
|
#mod(other) ⇒ Object
51
52
53
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 51
def mod(other)
Project.new(dao, aggregations, @projection, ['$mod' => keys + [other]])
end
|
#multiply(other) ⇒ Object
Also known as:
multiplied_by
41
42
43
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 41
def multiply(other)
Project.new(dao, aggregations, @projection, ['$multiply' => keys + [other]])
end
|
#project(*keys) ⇒ Object
Also known as:
and
18
19
20
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 18
def project(*keys)
Project.new(dao, aggregations, projection, keys)
end
|
#subtract(other) ⇒ Object
Also known as:
minus
46
47
48
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 46
def subtract(other)
Project.new(dao, aggregations, @projection, ['$subtract' => keys + [other]])
end
|
#to_aggregation ⇒ Object
14
15
16
|
# File 'lib/daodalus/dsl/aggregation/project.rb', line 14
def to_aggregation
{ '$project' => { '_id' => 0 }.merge(projection) }
end
|