aggregate() public method

Aggregate using pipeline
public aggregate ( callable | array | Pipeline $pipeline, array $options = [], boolean $asCursor = false ) : array
$pipeline callable | array | Pipeline list of pipeline stages
$options array
$asCursor boolean return result as cursor
return array result of aggregation
Example #1
0
 public function testAggregate_ResultAsCursor()
 {
     $this->collection->createDocument(array('param' => 1))->save();
     $this->collection->createDocument(array('param' => 2))->save();
     $this->collection->createDocument(array('param' => 3))->save();
     $this->collection->createDocument(array('param' => 4))->save();
     $pipeline = $this->collection->createAggregator()->match(array('param' => array('$gte' => 2)))->group(array('_id' => 0, 'sum' => array('$sum' => '$param')));
     $result = $this->collection->aggregate($pipeline, array(), true);
     $this->assertInstanceOf('\\MongoCommandCursor', $result);
 }
 public function aggregate()
 {
     return $this->collection->aggregate($this);
 }
Example #3
0
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Wrong pipeline specified
  */
 public function testAggregate_WrongArgument()
 {
     $this->collection->aggregate('hello');
 }
Example #4
0
 public function aggregateCursor(array $options = array())
 {
     return $this->collection->aggregate($this, $options, true);
 }