Documentation

Variable
in package

FinalYes

Enum for system variables that can be used in aggregation expressions.

Tags
see
https://www.mongodb.com/docs/manual/reference/aggregation-variables/

Table of Contents

Methods

clusterTime()  : ResolvesToTimestamp
A variable that returns the current timestamp value.
current()  : ResolvesToAny
References the start of the field path being processed in the aggregation pipeline stage.
descend()  : ExpressionInterface
One of the allowed results of a $redact expression.
keep()  : ExpressionInterface
One of the allowed results of a $redact expression.
now()  : ResolvesToDate
A variable that returns the current datetime value.
prune()  : ExpressionInterface
One of the allowed results of a $redact expression.
remove()  : ResolvesToAny
A variable which evaluates to the missing value. Allows for the conditional exclusion of fields. In a $project, a field set to the variable REMOVE is excluded from the output.
root()  : ResolvesToObject
References the root document, i.e. the top-level document, currently being processed in the aggregation pipeline stage.
searchMeta()  : ResolvesToObject
A variable that stores the metadata results of an Atlas Search query. In all supported aggregation pipeline stages, a field set to the variable $$SEARCH_META returns the metadata results for the query.
userRoles()  : ResolvesToArray
Returns the roles assigned to the current user.
variable()  : Variable
User-defined variable that can be used to store any BSON type.
__construct()  : mixed

Methods

clusterTime()

A variable that returns the current timestamp value.

public static clusterTime() : ResolvesToTimestamp

CLUSTER_TIME is only available on replica sets and sharded clusters. CLUSTER_TIME returns the same value for all members of the deployment and remains the same throughout all stages of the pipeline.

New in MongoDB 4.2.

Return values
ResolvesToTimestamp

current()

References the start of the field path being processed in the aggregation pipeline stage.

public static current([string $fieldPath = '' ]) : ResolvesToAny

Unless documented otherwise, all stages start with CURRENT the same as ROOT. CURRENT is modifiable. However, since $ is equivalent to $$CURRENT., rebinding CURRENT changes the meaning of $ accesses.

Parameters
$fieldPath : string = ''
Return values
ResolvesToAny

descend()

One of the allowed results of a $redact expression.

public static descend() : ExpressionInterface

$redact returns the fields at the current document level, excluding embedded documents. To include embedded documents and embedded documents within arrays, apply the $cond expression to the embedded documents to determine access for these embedded documents.

Tags
see
https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
Return values
ExpressionInterface

keep()

One of the allowed results of a $redact expression.

public static keep() : ExpressionInterface

$redact returns or keeps all fields at this current document/embedded document level, without further inspection of the fields at this level. This applies even if the included field contains embedded documents that may have different access levels.

Tags
see
https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
Return values
ExpressionInterface

now()

A variable that returns the current datetime value.

public static now() : ResolvesToDate

NOW returns the same value for all members of the deployment and remains the same throughout all stages of the aggregation pipeline.

New in MongoDB 4.2.

Return values
ResolvesToDate

prune()

One of the allowed results of a $redact expression.

public static prune() : ExpressionInterface

$redact excludes all fields at this current document/embedded document level, without further inspection of any of the excluded fields. This applies even if the excluded field contains embedded documents that may have different access levels.

Tags
see
https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
Return values
ExpressionInterface

userRoles()

Returns the roles assigned to the current user.

public static userRoles() : ResolvesToArray

For use cases that include USER_ROLES, see the find, aggregation, view, updateOne, updateMany, and findAndModify examples.

New in MongoDB 7.0.

Return values
ResolvesToArray

__construct()

private __construct() : mixed

        
On this page

Search results