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
コード例 #1
0
ファイル: PipelineTest.php プロジェクト: sokil/php-mongo
 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);
 }
コード例 #2
0
 public function aggregate()
 {
     return $this->collection->aggregate($this);
 }
コード例 #3
0
ファイル: PipelineTest.php プロジェクト: agolomazov/php-mongo
 /**
  * @expectedException \Sokil\Mongo\Exception
  * @expectedExceptionMessage Wrong pipeline specified
  */
 public function testAggregate_WrongArgument()
 {
     $this->collection->aggregate('hello');
 }
コード例 #4
0
ファイル: Pipeline.php プロジェクト: sokil/php-mongo
 public function aggregateCursor(array $options = array())
 {
     return $this->collection->aggregate($this, $options, true);
 }