File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -258,6 +258,26 @@ specifies all existing fields in the input documents and adds the new fields.
258258 ->field('purchaseYear')
259259 ->year('$purchaseDate');
260260
261+ You can also pass expressions as arrays:
262+
263+ .. code-block :: php
264+
265+ <?php
266+
267+ $builder = $dm->createAggregationBuilder(\Documents\Orders::class);
268+ $builder
269+ ->addFields()
270+ ->field('purchaseYear')
271+ ->expression(['$year' => '$purchaseDate'])
272+ ->field('multiply')
273+ ->expression(['$multiply' => ['$price', 2 ] ]);
274+
275+ This allows usage of any expression operators introduced by MongoDB, even
276+ if Doctrine ODM does not yet wrap it with convenience methods.
277+
278+ You can see all available expression operators at MongoDB documentation
279+ `here <https://docs.mongodb.com/manual/reference/operator/aggregation/ >`_.
280+
261281$bucket
262282~~~~~~~
263283
You can’t perform that action at this time.
0 commit comments