abstract class AbstractOutput extends Stage (View source)

Abstract class with common functionality for output objects in bucket stages

Properties

protected Builder $builder from Stage
protected AbstractBucket $bucket

Methods

__construct(Builder $builder, AbstractBucket $bucket)

No description

getExpression()

Assembles the aggregation stage

execute(array $options = [])

Executes the aggregation pipeline

from Stage
bucket()

Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.

from Stage
bucketAuto()

Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression.

from Stage
collStats()

Returns statistics regarding a collection or view.

from Stage
count(string $fieldName)

Returns a document that contains a count of the number of documents input to the stage.

from Stage
facet()

Processes multiple aggregation pipelines within a single stage on the same set of input documents.

from Stage
geoNear(float|array|Point $x, float $y = null)

Outputs documents in order of nearest to farthest from a specified point.

from Stage
getPipeline()

Returns the assembled aggregation pipeline

from Stage
graphLookup(string $from)

Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.

from Stage
group()

Groups documents by some specified expression and outputs to the next stage a document for each distinct grouping.

from Stage
indexStats()

Returns statistics regarding the use of each index for the collection.

from Stage
limit(int $limit)

Limits the number of documents passed to the next stage in the pipeline.

from Stage
lookup(string $from)

Performs a left outer join to an unsharded collection in the same database to filter in documents from the “joined” collection for processing.

from Stage
match()

Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.

from Stage
out(string $collection)

Takes the documents returned by the aggregation pipeline and writes them to a specified collection. This must be the last stage in the pipeline.

from Stage
project()

Passes along the documents with only the specified fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields.

from Stage
redact()

Restricts the contents of the documents based on information stored in the documents themselves.

from Stage
replaceRoot(string|array|null $expression = null)

Promotes a specified document to the top level and replaces all other fields.

from Stage
sample(int $size)

Randomly selects the specified number of documents from its input.

from Stage
skip(int $skip)

Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.

from Stage
sortByCount(string $expression)

Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group.

from Stage
sort(array|string $fieldName, int|string $order = null)

Sorts all input documents and returns them to the pipeline in sorted order.

from Stage
unwind(string $fieldName)

Deconstructs an array field from the input documents to output a document for each element. Each output document is the input document with the value of the array field replaced by the element.

from Stage
$this
addToSet(mixed|Expr $expression)

Returns an array of all unique values that results from applying an expression to each document in a group of documents that share the same group by key. Order of the elements in the output array is unspecified.

$this
avg(mixed|Expr $expression)

Returns the average value of the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

$this
expression(mixed|Expr $value)

Used to use an expression as field value. Can be any expression.

$this
field(string $fieldName)

Set the current field for building the expression.

$this
first(mixed|Expr $expression)

Returns the value that results from applying an expression to the first document in a group of documents that share the same group by key. Only meaningful when documents are in a defined order.

$this
last(mixed|Expr $expression)

Returns the value that results from applying an expression to the last document in a group of documents that share the same group by a field.

$this
max(mixed|Expr $expression)

Returns the highest value that results from applying an expression to each document in a group of documents that share the same group by key.

$this
min(mixed|Expr $expression)

Returns the lowest value that results from applying an expression to each document in a group of documents that share the same group by key.

$this
push(mixed|Expr $expression)

Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key.

$this
stdDevPop(mixed|Expr $expression)

Calculates the population standard deviation of the input values.

$this
stdDevSamp(mixed|Expr $expression)

Calculates the sample standard deviation of the input values.

$this
sum(mixed|Expr $expression)

Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

Details

__construct(Builder $builder, AbstractBucket $bucket)

Parameters

Builder $builder
AbstractBucket $bucket

getExpression()

Assembles the aggregation stage

execute(array $options = [])

Executes the aggregation pipeline

Parameters

array $options

bucket()

Categorizes incoming documents into groups, called buckets, based on a specified expression and bucket boundaries.

Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound of the bucket and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

bucketAuto()

Categorizes incoming documents into a specific number of groups, called buckets, based on a specified expression.

Bucket boundaries are automatically determined in an attempt to evenly distribute the documents into the specified number of buckets. Each bucket is represented as a document in the output. The document for each bucket contains an _id field, whose value specifies the inclusive lower bound and the exclusive upper bound for the bucket, and a count field that contains the number of documents in the bucket. The count field is included by default when the output is not specified.

collStats()

Returns statistics regarding a collection or view.

$collStats must be the first stage in an aggregation pipeline, or else the pipeline returns an error.

count(string $fieldName)

Returns a document that contains a count of the number of documents input to the stage.

facet()

Processes multiple aggregation pipelines within a single stage on the same set of input documents.

Each sub-pipeline has its own field in the output document where its results are stored as an array of documents.

geoNear(float|array|Point $x, float $y = null)

Outputs documents in order of nearest to farthest from a specified point.

You can only use this as the first stage of a pipeline.

Parameters

float|array|Point $x
float $y

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/geoNear/

getPipeline()

Returns the assembled aggregation pipeline

graphLookup(string $from)

Performs a recursive search on a collection, with options for restricting the search by recursion depth and query filter.

Parameters

string $from Target collection for the $graphLookup operation to search, recursively matching the connectFromField to the connectToField.

See also

https://docs.mongodb.org/manual/reference/operator/aggregation/graphLookup/

group()

Groups documents by some specified expression and outputs to the next stage a document for each distinct grouping.

indexStats()

Returns statistics regarding the use of each index for the collection.

Limit limit(int $limit)

Limits the number of documents passed to the next stage in the pipeline.

lookup(string $from)

Performs a left outer join to an unsharded collection in the same database to filter in documents from the “joined” collection for processing.

match()

Filters the documents to pass only the documents that match the specified condition(s) to the next pipeline stage.

out(string $collection)

Takes the documents returned by the aggregation pipeline and writes them to a specified collection. This must be the last stage in the pipeline.

project()

Passes along the documents with only the specified fields to the next stage in the pipeline. The specified fields can be existing fields from the input documents or newly computed fields.

redact()

Restricts the contents of the documents based on information stored in the documents themselves.

replaceRoot(string|array|null $expression = null)

Promotes a specified document to the top level and replaces all other fields.

The operation replaces all existing fields in the input document, including the _id field. You can promote an existing embedded document to the top level, or create a new document for promotion.

Parameters

string|array|null $expression Optional. A replacement expression that resolves to a document.

sample(int $size)

Randomly selects the specified number of documents from its input.

skip(int $skip)

Skips over the specified number of documents that pass into the stage and passes the remaining documents to the next stage in the pipeline.

sortByCount(string $expression)

Groups incoming documents based on the value of a specified expression, then computes the count of documents in each distinct group.

sort(array|string $fieldName, int|string $order = null)

Sorts all input documents and returns them to the pipeline in sorted order.

If sorting by multiple fields, the first argument should be an array of field name (key) and order (value) pairs.

Parameters

array|string $fieldName Field name or array of field/order pairs
int|string $order Field order (if one field is specified)

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/sort/

unwind(string $fieldName)

Deconstructs an array field from the input documents to output a document for each element. Each output document is the input document with the value of the array field replaced by the element.

$this addToSet(mixed|Expr $expression)

Returns an array of all unique values that results from applying an expression to each document in a group of documents that share the same group by key. Order of the elements in the output array is unspecified.

AddToSet is an accumulator operation only available in the group stage.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/addToSet/
Expr::addToSet

$this avg(mixed|Expr $expression)

Returns the average value of the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/avg/
Expr::avg

$this expression(mixed|Expr $value)

Used to use an expression as field value. Can be any expression.

Parameters

mixed|Expr $value

Return Value

$this

See also

http://docs.mongodb.org/manual/meta/aggregation-quick-reference/#aggregation-expressions
Expr::expression

$this field(string $fieldName)

Set the current field for building the expression.

Parameters

string $fieldName

Return Value

$this

See also

Expr::field

$this first(mixed|Expr $expression)

Returns the value that results from applying an expression to the first document in a group of documents that share the same group by key. Only meaningful when documents are in a defined order.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/first/
Expr::first

$this last(mixed|Expr $expression)

Returns the value that results from applying an expression to the last document in a group of documents that share the same group by a field.

Only meaningful when documents are in a defined order.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/last/
Expr::last

$this max(mixed|Expr $expression)

Returns the highest value that results from applying an expression to each document in a group of documents that share the same group by key.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/max/
Expr::max

$this min(mixed|Expr $expression)

Returns the lowest value that results from applying an expression to each document in a group of documents that share the same group by key.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/min/
Expr::min

$this push(mixed|Expr $expression)

Returns an array of all values that result from applying an expression to each document in a group of documents that share the same group by key.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/push/
Expr::push

$this stdDevPop(mixed|Expr $expression)

Calculates the population standard deviation of the input values.

The argument can be any expression as long as it resolves to an array.

Parameters

mixed|Expr $expression

Return Value

$this

See also

https://docs.mongodb.org/manual/reference/operator/aggregation/stdDevPop/
Expr::stdDevPop

$this stdDevSamp(mixed|Expr $expression)

Calculates the sample standard deviation of the input values.

The argument can be any expression as long as it resolves to an array.

Parameters

mixed|Expr $expression

Return Value

$this

See also

https://docs.mongodb.org/manual/reference/operator/aggregation/stdDevSamp/
Expr::stdDevSamp

$this sum(mixed|Expr $expression)

Calculates and returns the sum of all the numeric values that result from applying a specified expression to each document in a group of documents that share the same group by key. Ignores nun-numeric values.

Parameters

mixed|Expr $expression

Return Value

$this

See also

http://docs.mongodb.org/manual/reference/operator/aggregation/sum/
Expr::sum