Module: Daodalus::DSL::Aggregations

Instance Method Summary collapse

Instance Method Details

#aggregateObject



5
6
7
# File 'lib/daodalus/dsl/aggregations.rb', line 5

def aggregate
  dao.aggregate(pipeline)
end

#group(keys) ⇒ Object Also known as: group_by



13
14
15
# File 'lib/daodalus/dsl/aggregations.rb', line 13

def group(keys)
  Aggregation::Group.new(dao, pipeline, keys, {})
end

#limit(limit) ⇒ Object



22
23
24
# File 'lib/daodalus/dsl/aggregations.rb', line 22

def limit(limit)
  Aggregation::Limit.new(dao, pipeline, limit)
end

#match(field = nil) ⇒ Object



9
10
11
# File 'lib/daodalus/dsl/aggregations.rb', line 9

def match(field=nil)
  Aggregation::Match.new(dao, pipeline, Query.new, field)
end

#pipelineObject



38
39
40
# File 'lib/daodalus/dsl/aggregations.rb', line 38

def pipeline
  aggregations + [to_aggregation]
end

#project(*keys) ⇒ Object



18
19
20
# File 'lib/daodalus/dsl/aggregations.rb', line 18

def project(*keys)
  Aggregation::Project.new(dao, pipeline, keys)
end

#skip(skip) ⇒ Object



26
27
28
# File 'lib/daodalus/dsl/aggregations.rb', line 26

def skip(skip)
  Aggregation::Skip.new(dao, pipeline, skip)
end

#sort(sort) ⇒ Object



30
31
32
# File 'lib/daodalus/dsl/aggregations.rb', line 30

def sort(sort)
  Aggregation::Sort.new(dao, pipeline, sort)
end

#unwind(field) ⇒ Object



34
35
36
# File 'lib/daodalus/dsl/aggregations.rb', line 34

def unwind(field)
  Aggregation::Unwind.new(dao, pipeline, field)
end