# Project

class
**Project** extends Operator (View source)

Fluent interface for adding a $project stage to an aggregation pipeline.

## Properties

protected Builder | $builder | from Stage | |

protected Expr | $expr | from Operator |

## Methods

Assembles the aggregation stage

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

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

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

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

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

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

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

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

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

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

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

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.

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

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

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

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

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

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.

Adds numbers together or adds numbers and a date. If one of the arguments is a date, $add treats the other arguments as milliseconds to add to the date.

Add one or more $and clauses to the current expression.

Add one or more $or clauses to the current expression.

Evaluates an array as a set and returns true if no element in the array is false. Otherwise, returns false. An empty array returns true.

Evaluates an array as a set and returns true if any of the elements are true and false otherwise. An empty array returns false.

Returns the smallest integer greater than or equal to the specified number.

Compares two values and returns: -1 if the first value is less than the second.

Concatenates strings and returns the concatenated string.

Concatenates arrays to return the concatenated array.

Evaluates a boolean expression to return one of the two specified return expressions.

Converts a date object to a string according to a user-specified format.

Returns the day of the month for a date as a number between 1 and 31.

Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).

Returns the day of the year for a date as a number between 1 and 366.

Divides one number by another and returns the result. The first argument is divided by the second argument.

Compares two values and returns whether they are equivalent.

Selects a subset of the array to return based on the specified condition.

Compares two values and returns: true when the first value is greater than the second value.

Compares two values and returns: true when the first value is greater than or equivalent to the second value.

Returns a boolean indicating whether a specified value is in an array.

Searches an array for an occurrence of a specified value and returns the array index (zero-based) of the first occurrence. If the value is not found, returns -1.

Searches a string for an occurrence of a substring and returns the UTF-8 byte index (zero-based) of the first occurrence. If the substring is not found, returns -1.

Searches a string for an occurrence of a substring and returns the UTF-8 code point index (zero-based) of the first occurrence. If the substring is not found, returns -1.

Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value. If the expression evaluates to a null value, including instances of undefined values or missing fields, returns the value of the replacement expression.

Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday).

Binds variables for use in the specified expression, and returns the result of the expression.

Returns a value without parsing. Use for values that the aggregation pipeline may interpret as an expression.

Calculates the natural logarithm ln (i.e loge) of a number and returns the result as a double.

Calculates the log of a number in the specified base and returns the result as a double.

Calculates the log base 10 of a number and returns the result as a double.

Compares two values and returns: true when the first value is less than the second value.

Compares two values and returns: true when the first value is less than or equivalent to the second value.

Applies an expression to each item in an array and returns an array with the applied results.

Returns the metadata associated with a document in a pipeline operations.

Returns the millisecond portion of a date as an integer between 0 and 999.

Divides one number by another and returns the remainder. The first argument is divided by the second argument.

Multiplies numbers together and returns the result.

Compares two values and returns: true when the values are not equivalent.

Raises a number to the specified exponent and returns the result.

Returns an array whose elements are a generated sequence of numbers.

Applies an expression to each element in an array and combines them into a single value.

Accepts an array expression as an argument and returns an array with the elements in reverse order.

Returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds.

Takes two sets and returns an array containing the elements that only exist in the first set.

Compares two or more arrays and returns true if they have the same distinct elements and false otherwise.

Takes two or more arrays and returns an array that contains the elements that appear in every input array.

Takes two arrays and returns true when the first array is a subset of the second, including when the first array equals the second array, and false otherwise.

Takes two or more arrays and returns an array containing the elements that appear in any input array.

Returns a subset of an array.

Divides a string into an array of substrings based on a delimiter.

Calculates the square root of a positive number and returns the result as a double.

Performs case-insensitive comparison of two strings. Returns 1 if first string is “greater than” the second string.

Returns a substring of a string, starting at a specified index position and including the specified number of characters. The index is zero-based.

Returns the substring of a string.

Returns the substring of a string.

Subtracts two numbers to return the difference. The second argument is subtracted from the first argument.

Transposes an array of input arrays so that the first element of the output array would be an array containing, the first element of the first input array, the first element of the second input array, etc.

Shorthand method to define which fields to be included.

Shorthand method to define which fields to be excluded.

Calculates the sample standard deviation of the input values.

## Details

###
at line 18
```
```**getExpression**()

**getExpression**()

Assembles the aggregation stage

###
```
```**bucket**()

**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**()

**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**()

**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)

**count**(string $fieldName)

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

###
```
```**facet**()

**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)

**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.

###
```
```**graphLookup**(string $from)

**graphLookup**(string $from)

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

###
```
```**group**()

**group**()

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

###
```
```**indexStats**()

**indexStats**()

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

###
```
Limit
```**limit**(int $limit)

**limit**(int $limit)

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

###
```
```**lookup**(string $from)

**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**()

**match**()

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

###
```
```**out**(string $collection)

**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**()

**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**()

**redact**()

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

###
```
```**replaceRoot**(string|array|null $expression = null)

**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.

###
```
```**sample**(int $size)

**sample**(int $size)

Randomly selects the specified number of documents from its input.

###
```
```**skip**(int $skip)

**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)

**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)

**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.

###
```
```**unwind**(string $fieldName)

**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.

###
```
```**abs**(mixed|Expr $number)

**abs**(mixed|Expr $number)

Returns the absolute value of a number.

The

###
```
```**add**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

**add**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

Adds numbers together or adds numbers and a date. If one of the arguments is a date, $add treats the other arguments as milliseconds to add to the date.

The arguments can be any valid expression as long as they resolve to either all numbers or to numbers and a date.

###
```
```**addAnd**(array|Expr $expression, array|Expr ...$expressions)

**addAnd**(array|Expr $expression, array|Expr ...$expressions)

Add one or more $and clauses to the current expression.

###
```
```**addOr**(array|Expr $expression, array|Expr ...$expressions)

**addOr**(array|Expr $expression, array|Expr ...$expressions)

Add one or more $or clauses to the current expression.

###
```
```**allElementsTrue**(mixed|Expr $expression)

**allElementsTrue**(mixed|Expr $expression)

Evaluates an array as a set and returns true if no element in the array is false. Otherwise, returns false. An empty array returns true.

The expression must resolve to an array.

###
```
```**anyElementTrue**(array|Expr $expression)

**anyElementTrue**(array|Expr $expression)

Evaluates an array as a set and returns true if any of the elements are true and false otherwise. An empty array returns false.

The expression must resolve to an array.

###
```
```**arrayElemAt**(mixed|Expr $array, mixed|Expr $index)

**arrayElemAt**(mixed|Expr $array, mixed|Expr $index)

Returns the element at the specified array index.

The

###
```
```**ceil**(mixed|Expr $number)

**ceil**(mixed|Expr $number)

Returns the smallest integer greater than or equal to the specified number.

The

###
```
```**cmp**(mixed|Expr $expression1, mixed|Expr $expression2)

**cmp**(mixed|Expr $expression1, mixed|Expr $expression2)

Compares two values and returns: -1 if the first value is less than the second.

1 if the first value is greater than the second. 0 if the two values are equivalent.

###
```
```**concat**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

**concat**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

Concatenates strings and returns the concatenated string.

The arguments can be any valid expression as long as they resolve to strings. If the argument resolves to a value of null or refers to a field that is missing, $concat returns null.

###
```
```**concatArrays**(mixed|Expr $array1, mixed|Expr $array2, mixed|Expr ...$arrays)

**concatArrays**(mixed|Expr $array1, mixed|Expr $array2, mixed|Expr ...$arrays)

Concatenates arrays to return the concatenated array.

The

###
```
```**cond**(mixed|Expr $if, mixed|Expr $then, mixed|Expr $else)

**cond**(mixed|Expr $if, mixed|Expr $then, mixed|Expr $else)

Evaluates a boolean expression to return one of the two specified return expressions.

The arguments can be any valid expression.

###
```
```**dateToString**(string $format, mixed|Expr $expression)

**dateToString**(string $format, mixed|Expr $expression)

Converts a date object to a string according to a user-specified format.

The format string can be any string literal, containing 0 or more format specifiers. The date argument can be any expression as long as it resolves to a date.

###
```
```**dayOfMonth**(mixed|Expr $expression)

**dayOfMonth**(mixed|Expr $expression)

Returns the day of the month for a date as a number between 1 and 31.

The argument can be any expression as long as it resolves to a date.

###
```
```**dayOfWeek**(mixed|Expr $expression)

**dayOfWeek**(mixed|Expr $expression)

Returns the day of the week for a date as a number between 1 (Sunday) and 7 (Saturday).

The argument can be any expression as long as it resolves to a date.

###
```
```**dayOfYear**(mixed|Expr $expression)

**dayOfYear**(mixed|Expr $expression)

Returns the day of the year for a date as a number between 1 and 366.

The argument can be any expression as long as it resolves to a date.

###
```
```**divide**(mixed|Expr $expression1, mixed|Expr $expression2)

**divide**(mixed|Expr $expression1, mixed|Expr $expression2)

Divides one number by another and returns the result. The first argument is divided by the second argument.

The arguments can be any valid expression as long as the resolve to numbers.

###
```
```**eq**(mixed|Expr $expression1, mixed|Expr $expression2)

**eq**(mixed|Expr $expression1, mixed|Expr $expression2)

Compares two values and returns whether they are equivalent.

###
```
```**exp**(mixed|Expr $exponent)

**exp**(mixed|Expr $exponent)

Raises Euler’s number to the specified exponent and returns the result.

The

###
```
```**expression**(mixed|Expr $value)

**expression**(mixed|Expr $value)

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

###
```
```**filter**(mixed|Expr $input, mixed|Expr $as, mixed|Expr $cond)

**filter**(mixed|Expr $input, mixed|Expr $as, mixed|Expr $cond)

Selects a subset of the array to return based on the specified condition.

Returns an array with only those elements that match the condition. The returned elements are in the original order.

###
```
```**floor**(mixed|Expr $number)

**floor**(mixed|Expr $number)

Returns the largest integer less than or equal to the specified number.

The

###
```
```**gt**(mixed|Expr $expression1, mixed|Expr $expression2)

**gt**(mixed|Expr $expression1, mixed|Expr $expression2)

Compares two values and returns: true when the first value is greater than the second value.

false when the first value is less than or equivalent to the second value.

###
```
```**gte**(mixed|Expr $expression1, mixed|Expr $expression2)

**gte**(mixed|Expr $expression1, mixed|Expr $expression2)

Compares two values and returns: true when the first value is greater than or equivalent to the second value.

false when the first value is less than the second value.

###
```
```**hour**(mixed|Expr $expression)

**hour**(mixed|Expr $expression)

Returns the hour portion of a date as a number between 0 and 23.

The argument can be any expression as long as it resolves to a date.

###
```
```**in**(mixed|Expr $expression, mixed|Expr $arrayExpression)

**in**(mixed|Expr $expression, mixed|Expr $arrayExpression)

Returns a boolean indicating whether a specified value is in an array.

Unlike the $in query operator, the aggregation $in operator does not support matching by regular expressions.

###
```
```**indexOfArray**(mixed|Expr $arrayExpression, mixed|Expr $searchExpression, mixed|Expr $start = null, mixed|Expr $end = null)

**indexOfArray**(mixed|Expr $arrayExpression, mixed|Expr $searchExpression, mixed|Expr $start = null, mixed|Expr $end = null)

Searches an array for an occurrence of a specified value and returns the array index (zero-based) of the first occurrence. If the value is not found, returns -1.

###
```
```**indexOfBytes**(mixed|Expr $stringExpression, mixed|Expr $substringExpression, string|int|null $start = null, string|int|null $end = null)

**indexOfBytes**(mixed|Expr $stringExpression, mixed|Expr $substringExpression, string|int|null $start = null, string|int|null $end = null)

Searches a string for an occurrence of a substring and returns the UTF-8 byte index (zero-based) of the first occurrence. If the substring is not found, returns -1.

###
```
```**indexOfCP**(mixed|Expr $stringExpression, mixed|Expr $substringExpression, string|int|null $start = null, string|int|null $end = null)

**indexOfCP**(mixed|Expr $stringExpression, mixed|Expr $substringExpression, string|int|null $start = null, string|int|null $end = null)

Searches a string for an occurrence of a substring and returns the UTF-8 code point index (zero-based) of the first occurrence. If the substring is not found, returns -1.

###
```
```**ifNull**(mixed|Expr $expression, mixed|Expr $replacementExpression)

**ifNull**(mixed|Expr $expression, mixed|Expr $replacementExpression)

Evaluates an expression and returns the value of the expression if the expression evaluates to a non-null value. If the expression evaluates to a null value, including instances of undefined values or missing fields, returns the value of the replacement expression.

The arguments can be any valid expression.

###
```
```**isArray**(mixed|Expr $expression)

**isArray**(mixed|Expr $expression)

Determines if the operand is an array. Returns a boolean.

The

###
```
```**isoDayOfWeek**(mixed|Expr $expression)

**isoDayOfWeek**(mixed|Expr $expression)

Returns the weekday number in ISO 8601 format, ranging from 1 (for Monday) to 7 (for Sunday).

The argument can be any expression as long as it resolves to a date.

###
```
```**isoWeek**(mixed|Expr $expression)

**isoWeek**(mixed|Expr $expression)

Returns the week number in ISO 8601 format, ranging from 1 to 53.

Week numbers start at 1 with the week (Monday through Sunday) that contains the year’s first Thursday.

The argument can be any expression as long as it resolves to a date.

###
```
```**isoWeekYear**(mixed|Expr $expression)

**isoWeekYear**(mixed|Expr $expression)

Returns the year number in ISO 8601 format.

The year starts with the Monday of week 1 (ISO 8601) and ends with the Sunday of the last week (ISO 8601).

The argument can be any expression as long as it resolves to a date.

###
```
```**let**(mixed|Expr $vars, mixed|Expr $in)

**let**(mixed|Expr $vars, mixed|Expr $in)

Binds variables for use in the specified expression, and returns the result of the expression.

###
```
```**literal**(mixed|Expr $value)

**literal**(mixed|Expr $value)

Returns a value without parsing. Use for values that the aggregation pipeline may interpret as an expression.

###
```
```**ln**(mixed|Expr $number)

**ln**(mixed|Expr $number)

Calculates the natural logarithm ln (i.e loge) of a number and returns the result as a double.

The

###
```
```**log**(mixed|Expr $number, mixed|Expr $base)

**log**(mixed|Expr $number, mixed|Expr $base)

Calculates the log of a number in the specified base and returns the result as a double.

The

###
```
```**log10**(mixed|Expr $number)

**log10**(mixed|Expr $number)

Calculates the log base 10 of a number and returns the result as a double.

The

###
```
```**lt**(mixed|Expr $expression1, mixed|Expr $expression2)

**lt**(mixed|Expr $expression1, mixed|Expr $expression2)

Compares two values and returns: true when the first value is less than the second value.

false when the first value is greater than or equivalent to the second value.

###
```
```**lte**(mixed|Expr $expression1, mixed|Expr $expression2)

**lte**(mixed|Expr $expression1, mixed|Expr $expression2)

Compares two values and returns: true when the first value is less than or equivalent to the second value.

false when the first value is greater than the second value.

###
```
```**map**(mixed|Expr $input, string $as, mixed|Expr $in)

**map**(mixed|Expr $input, string $as, mixed|Expr $in)

Applies an expression to each item in an array and returns an array with the applied results.

###
```
```**meta**(mixed|Expr $metaDataKeyword)

**meta**(mixed|Expr $metaDataKeyword)

Returns the metadata associated with a document in a pipeline operations.

###
```
```**millisecond**(mixed|Expr $expression)

**millisecond**(mixed|Expr $expression)

Returns the millisecond portion of a date as an integer between 0 and 999.

The argument can be any expression as long as it resolves to a date.

###
```
```**minute**(mixed|Expr $expression)

**minute**(mixed|Expr $expression)

Returns the minute portion of a date as a number between 0 and 59.

The argument can be any expression as long as it resolves to a date.

###
```
```**mod**(mixed|Expr $expression1, mixed|Expr $expression2)

**mod**(mixed|Expr $expression1, mixed|Expr $expression2)

Divides one number by another and returns the remainder. The first argument is divided by the second argument.

The arguments can be any valid expression as long as they resolve to numbers.

###
```
```**month**(mixed|Expr $expression)

**month**(mixed|Expr $expression)

Returns the month of a date as a number between 1 and 12.

The argument can be any expression as long as it resolves to a date.

###
```
```**multiply**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

**multiply**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

Multiplies numbers together and returns the result.

The arguments can be any valid expression as long as they resolve to numbers.

###
```
```**ne**(mixed|Expr $expression1, mixed|Expr $expression2)

**ne**(mixed|Expr $expression1, mixed|Expr $expression2)

Compares two values and returns: true when the values are not equivalent.

false when the values are equivalent.

###
```
```**not**(mixed|Expr $expression)

**not**(mixed|Expr $expression)

Evaluates a boolean and returns the opposite boolean value.

###
```
```**pow**(mixed|Expr $number, mixed|Expr $exponent)

**pow**(mixed|Expr $number, mixed|Expr $exponent)

Raises a number to the specified exponent and returns the result.

The

###
```
```**range**(mixed|Expr $start, mixed|Expr $end, mixed|Expr $step = 1)

**range**(mixed|Expr $start, mixed|Expr $end, mixed|Expr $step = 1)

Returns an array whose elements are a generated sequence of numbers.

$range generates the sequence from the specified starting number by successively incrementing the starting number by the specified step value up to but not including the end point.

###
```
```**reduce**(mixed|Expr $input, mixed|Expr $initialValue, mixed|Expr $in)

**reduce**(mixed|Expr $input, mixed|Expr $initialValue, mixed|Expr $in)

Applies an expression to each element in an array and combines them into a single value.

###
```
```**reverseArray**(mixed|Expr $expression)

**reverseArray**(mixed|Expr $expression)

Accepts an array expression as an argument and returns an array with the elements in reverse order.

###
```
```**second**(mixed|Expr $expression)

**second**(mixed|Expr $expression)

Returns the second portion of a date as a number between 0 and 59, but can be 60 to account for leap seconds.

The argument can be any expression as long as it resolves to a date.

###
```
```**setDifference**(mixed|Expr $expression1, mixed|Expr $expression2)

**setDifference**(mixed|Expr $expression1, mixed|Expr $expression2)

Takes two sets and returns an array containing the elements that only exist in the first set.

The arguments can be any valid expression as long as they each resolve to an array.

###
```
```**setEquals**($expression1, $expression2, ...$expressions)

**setEquals**($expression1, $expression2, ...$expressions)

Compares two or more arrays and returns true if they have the same distinct elements and false otherwise.

The arguments can be any valid expression as long as they each resolve to an array.

###
```
```**setIntersection**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

**setIntersection**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

Takes two or more arrays and returns an array that contains the elements that appear in every input array.

The arguments can be any valid expression as long as they each resolve to an array.

###
```
```**setIsSubset**(mixed|Expr $expression1, mixed|Expr $expression2)

**setIsSubset**(mixed|Expr $expression1, mixed|Expr $expression2)

Takes two arrays and returns true when the first array is a subset of the second, including when the first array equals the second array, and false otherwise.

The arguments can be any valid expression as long as they each resolve to an array.

###
```
```**setUnion**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

**setUnion**(mixed|Expr $expression1, mixed|Expr $expression2, mixed|Expr ...$expressions)

Takes two or more arrays and returns an array containing the elements that appear in any input array.

The arguments can be any valid expression as long as they each resolve to an array.

###
```
```**size**(mixed|Expr $expression)

**size**(mixed|Expr $expression)

Counts and returns the total the number of items in an array.

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

###
```
```**slice**(mixed|Expr $array, mixed|Expr $n, mixed|Expr|null $position = null)

**slice**(mixed|Expr $array, mixed|Expr $n, mixed|Expr|null $position = null)

Returns a subset of an array.

###
```
```**split**(mixed|Expr $string, mixed|Expr $delimiter)

**split**(mixed|Expr $string, mixed|Expr $delimiter)

Divides a string into an array of substrings based on a delimiter.

$split removes the delimiter and returns the resulting substrings as elements of an array. If the delimiter is not found in the string, $split returns the original string as the only element of an array.

###
```
```**sqrt**(mixed|Expr $expression)

**sqrt**(mixed|Expr $expression)

Calculates the square root of a positive number and returns the result as a double.

The argument can be any valid expression as long as it resolves to a non-negative number.

###
```
```**strcasecmp**(mixed|Expr $expression1, mixed|Expr $expression2)

**strcasecmp**(mixed|Expr $expression1, mixed|Expr $expression2)

Performs case-insensitive comparison of two strings. Returns 1 if first string is “greater than” the second string.

0 if the two strings are equal. -1 if the first string is “less than” the second string.

The arguments can be any valid expression as long as they resolve to strings.

###
```
```**strLenBytes**(mixed|Expr $string)

**strLenBytes**(mixed|Expr $string)

Returns the number of UTF-8 encoded bytes in the specified string.

###
```
```**strLenCP**(mixed|Expr $string)

**strLenCP**(mixed|Expr $string)

Returns the number of UTF-8 code points in the specified string.

###
```
```**substr**(mixed|Expr $string, mixed|Expr $start, mixed|Expr $length)

**substr**(mixed|Expr $string, mixed|Expr $start, mixed|Expr $length)

Returns a substring of a string, starting at a specified index position and including the specified number of characters. The index is zero-based.

The arguments can be any valid expression as long as long as the first argument resolves to a string, and the second and third arguments resolve to integers.

###
```
```**substrBytes**(mixed|Expr $string, mixed|Expr $start, mixed|Expr $count)

**substrBytes**(mixed|Expr $string, mixed|Expr $start, mixed|Expr $count)

Returns the substring of a string.

The substring starts with the character at the specified UTF-8 byte index (zero-based) in the string and continues for the number of bytes specified.

###
```
```**substrCP**(mixed|Expr $string, mixed|Expr $start, mixed|Expr $count)

**substrCP**(mixed|Expr $string, mixed|Expr $start, mixed|Expr $count)

Returns the substring of a string.

The substring starts with the character at the specified UTF-8 code point (CP) index (zero-based) in the string for the number of code points specified.

###
```
```**subtract**(mixed|Expr $expression1, mixed|Expr $expression2)

**subtract**(mixed|Expr $expression1, mixed|Expr $expression2)

Subtracts two numbers to return the difference. The second argument is subtracted from the first argument.

The arguments can be any valid expression as long as they resolve to numbers and/or dates.

###
```
```**toLower**(mixed|Expr $expression)

**toLower**(mixed|Expr $expression)

Converts a string to lowercase, returning the result.

The argument can be any expression as long as it resolves to a string.

###
```
```**toUpper**(mixed|Expr $expression)

**toUpper**(mixed|Expr $expression)

Converts a string to uppercase, returning the result.

The argument can be any expression as long as it resolves to a string.

###
```
```**trunc**(mixed|Expr $number)

**trunc**(mixed|Expr $number)

Truncates a number to its integer.

The

###
```
```**type**(mixed|Expr $expression)

**type**(mixed|Expr $expression)

Returns a string that specifies the BSON type of the argument.

The argument can be any valid expression.

###
```
```**week**(mixed|Expr $expression)

**week**(mixed|Expr $expression)

Returns the week of the year for a date as a number between 0 and 53.

The argument can be any expression as long as it resolves to a date.

###
```
```**year**(mixed|Expr $expression)

**year**(mixed|Expr $expression)

Returns the year portion of a date.

The argument can be any expression as long as it resolves to a date.

###
```
```**zip**(mixed|Expr $inputs, bool|null $useLongestLength = null, mixed|Expr|null $defaults = null)

**zip**(mixed|Expr $inputs, bool|null $useLongestLength = null, mixed|Expr|null $defaults = null)

Transposes an array of input arrays so that the first element of the output array would be an array containing, the first element of the first input array, the first element of the second input array, etc.

###
at line 36
```
```**avg**(mixed|Expr $expression1, mixed|Expr ...$expressions)

**avg**(mixed|Expr $expression1, mixed|Expr ...$expressions)

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.

###
at line 46
```
```**includeFields**(array $fields)

**includeFields**(array $fields)

Shorthand method to define which fields to be included.

###
at line 61
```
```**excludeFields**(array $fields)

**excludeFields**(array $fields)

Shorthand method to define which fields to be excluded.

If you specify the exclusion of a field other than _id, you cannot employ any other $project specification forms.

###
at line 80
```
```**max**(mixed|Expr $expression1, mixed|Expr ...$expressions)

**max**(mixed|Expr $expression1, mixed|Expr ...$expressions)

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.

###
at line 97
```
```**min**(mixed|Expr $expression1, mixed|Expr ...$expressions)

**min**(mixed|Expr $expression1, mixed|Expr ...$expressions)

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.

###
at line 115
```
```**stdDevPop**(mixed|Expr $expression1, mixed|Expr ...$expressions)

**stdDevPop**(mixed|Expr $expression1, mixed|Expr ...$expressions)

Calculates the population standard deviation of the input values.

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