Doctrine\MongoDB\Aggregation\Builder::sample PHP Method

sample() public method

Randomly selects the specified number of documents from its input.
See also: https://docs.mongodb.org/manual/reference/operator/aggregation/sample/
public sample ( integer $size ) : Doctrine\MongoDB\Aggregation\Stage\Sample
$size integer
return Doctrine\MongoDB\Aggregation\Stage\Sample
    public function sample($size)
    {
        return $this->addStage(new Stage\Sample($this, $size));
    }

Usage Example

Beispiel #1
0
 /**
  * Randomly selects the specified number of documents from its input.
  *
  * @see https://docs.mongodb.org/manual/reference/operator/aggregation/sample/
  *
  * @param integer $size
  * @return Stage\Sample
  */
 public function sample($size)
 {
     return $this->builder->sample($size);
 }