-
Notifications
You must be signed in to change notification settings - Fork 232
Closed
Description
I am trying to achieve replaceRoot in doctrine. Seems there is some issue or am not sure if I am missing something.
[
{ "$unwind": "$data" },
{ "$match": { "$and": [ { "key": "885_2018_" } ] } },
{ "$group": { "_id": "null", "ranked": { "$push": "$data" } } },
{ "$unwind": { "path": "$ranked", "includeArrayIndex": "rank" } },
{ "$addFields": {"ranked.rank": { $add: [ "$rank", 1] }} },
{ "$replaceRoot": { "newRoot": "$ranked" } }
]);
I am trying to do the above mongo aggregation stage in Doctrine. Could you please help if this is a bug in Mongo ODM.
$builder = $this->createAggregationBuilder();
$groupByStage = $builder->group()->field('_id')->expression('null');
$groupByStage->field('ranked')->push('$data');
$groupByStage->unwind('$ranked')->includeArrayIndex('rank');
$builder->replaceRoot('$ranked');
I am getting the below error
'expected an object as specification for $replaceRoot stage, got string', 'stackTrace' => '#0 /api-r3/vendor/mongodb/mongodb/src/Operation/DatabaseCommand.php(94)
Metadata
Metadata
Assignees
Labels
No labels