Class: Moped::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/patches/aggregate_cursor.rb

Instance Method Summary collapse

Instance Method Details

#aggregate(*pipeline) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/patches/aggregate_cursor.rb', line 7

def aggregate(*pipeline)
  pipeline.flatten!
  command = { aggregate: name.to_s, pipeline: pipeline, cursor: {} }
  result = database.session.command(command)['cursor']
  result = result['firstBatch'] if result
  result
end