Variable
in package
Enum for system variables that can be used in aggregation expressions.
Tags
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
ResolvesToTimestampcurrent()
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 $
Parameters
- $fieldPath : string = ''
Return values
ResolvesToAnydescend()
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
Return values
ExpressionInterfacekeep()
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
Return values
ExpressionInterfacenow()
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
ResolvesToDateprune()
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
Return values
ExpressionInterfaceremove()
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.
public
static remove() : ResolvesToAny
Can be used with $cond operator for conditionally exclude fields.
Tags
Return values
ResolvesToAnyroot()
References the root document, i.e. the top-level document, currently being processed in the aggregation pipeline stage.
public
static root() : ResolvesToObject
Return values
ResolvesToObjectsearchMeta()
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.
public
static searchMeta() : ResolvesToObject
For an example of its usage, see Atlas Search facet and count.
Tags
Return values
ResolvesToObjectuserRoles()
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
ResolvesToArrayvariable()
User-defined variable that can be used to store any BSON type.
public
static variable(string $name) : Variable
Parameters
- $name : string
Tags
Return values
Variable__construct()
private
__construct() : mixed