18
18
*/
19
19
final class Variable
20
20
{
21
- /**
22
- * A variable that returns the current datetime value.
23
- * NOW returns the same value for all members of the deployment and remains the same throughout all stages of the
24
- * aggregation pipeline.
25
- *
26
- * New in MongoDB 4.2.
27
- */
28
- public static function now (): ResolvesToDate
29
- {
30
- return new Expression \Variable ('NOW ' );
31
- }
32
-
33
21
/**
34
22
* A variable that returns the current timestamp value.
35
23
* CLUSTER_TIME is only available on replica sets and sharded clusters.
@@ -43,15 +31,6 @@ public static function clusterTime(): ResolvesToTimestamp
43
31
return new Expression \Variable ('CLUSTER_TIME ' );
44
32
}
45
33
46
- /**
47
- * References the root document, i.e. the top-level document, currently being processed in the aggregation pipeline
48
- * stage.
49
- */
50
- public static function root (): ResolvesToObject
51
- {
52
- return new Expression \Variable ('ROOT ' );
53
- }
54
-
55
34
/**
56
35
* References the start of the field path being processed in the aggregation pipeline stage.
57
36
* Unless documented otherwise, all stages start with CURRENT the same as ROOT.
@@ -64,29 +43,43 @@ public static function current(string $fieldPath = ''): ResolvesToAny
64
43
}
65
44
66
45
/**
67
- * A variable which evaluates to the missing value. Allows for the conditional exclusion of fields. In a $project,
68
- * a field set to the variable REMOVE is excluded from the output.
69
- * Can be used with $cond operator for conditionally exclude fields.
46
+ * One of the allowed results of a $redact expression.
70
47
*
71
- * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#std-label-remove-example
48
+ * $redact returns the fields at the current document level, excluding embedded documents. To include embedded
49
+ * documents and embedded documents within arrays, apply the $cond expression to the embedded documents to determine
50
+ * access for these embedded documents.
51
+ *
52
+ * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
72
53
*/
73
- public static function remove (): ResolvesToAny
54
+ public static function descend (): ExpressionInterface
74
55
{
75
- return new Expression \Variable ('REMOVE ' );
56
+ return new Expression \Variable ('DESCEND ' );
76
57
}
77
58
78
59
/**
79
60
* One of the allowed results of a $redact expression.
80
61
*
81
- * $redact returns the fields at the current document level, excluding embedded documents. To include embedded
82
- * documents and embedded documents within arrays, apply the $cond expression to the embedded documents to determine
83
- * access for these embedded documents .
62
+ * $redact returns or keeps all fields at this current document/embedded document level, without further inspection
63
+ * of the fields at this level. This applies even if the included field contains embedded documents that may have
64
+ * different access levels .
84
65
*
85
66
* @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
86
67
*/
87
- public static function descend (): ExpressionInterface
68
+ public static function keep (): ExpressionInterface
88
69
{
89
- return new Expression \Variable ('DESCEND ' );
70
+ return new Expression \Variable ('KEEP ' );
71
+ }
72
+
73
+ /**
74
+ * A variable that returns the current datetime value.
75
+ * NOW returns the same value for all members of the deployment and remains the same throughout all stages of the
76
+ * aggregation pipeline.
77
+ *
78
+ * New in MongoDB 4.2.
79
+ */
80
+ public static function now (): ResolvesToDate
81
+ {
82
+ return new Expression \Variable ('NOW ' );
90
83
}
91
84
92
85
/**
@@ -104,17 +97,24 @@ public static function prune(): ExpressionInterface
104
97
}
105
98
106
99
/**
107
- * One of the allowed results of a $redact expression.
108
- *
109
- * $redact returns or keeps all fields at this current document/embedded document level, without further inspection
110
- * of the fields at this level. This applies even if the included field contains embedded documents that may have
111
- * different access levels.
100
+ * A variable which evaluates to the missing value. Allows for the conditional exclusion of fields. In a $project,
101
+ * a field set to the variable REMOVE is excluded from the output.
102
+ * Can be used with $cond operator for conditionally exclude fields.
112
103
*
113
- * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/redact/#mongodb-pipeline-pipe.-redact
104
+ * @see https://www.mongodb.com/docs/manual/reference/operator/aggregation/project/#std-label-remove-example
114
105
*/
115
- public static function keep (): ExpressionInterface
106
+ public static function remove (): ResolvesToAny
116
107
{
117
- return new Expression \Variable ('KEEP ' );
108
+ return new Expression \Variable ('REMOVE ' );
109
+ }
110
+
111
+ /**
112
+ * References the root document, i.e. the top-level document, currently being processed in the aggregation pipeline
113
+ * stage.
114
+ */
115
+ public static function root (): ResolvesToObject
116
+ {
117
+ return new Expression \Variable ('ROOT ' );
118
118
}
119
119
120
120
/**
0 commit comments