Hi,
I’ve just upgraded to MongoDB 5.0 and have to say I’m loving the new features. $rank is making things a lot cleaner for my aggregations.
I receiving the following error when running $setWindowFields and $rank in PHP
(None) must be specified with ‘{}’ as the value
The following code runs in MongoDB shell
{
"$setWindowFields" : {
"partitionBy" : {
"split" : "$split_id"
},
"sortBy" : {
"time" : 1.0
},
"output" : {
"position" : {
"$rank" : {
}
},
"leader" : {
"$first" : "$time"
}
}
}
}
The below in PHP produces the above error.
[
'$setWindowFields' => [
'partitionBy' => [
'split' => '$split_id'
],
'sortBy' => [
'time' => 1.0
],
'output' => [
'position' => [
'$rank' => []
],
'leader' => [
'$first' => '$time'
]
]
]
],
Any thoughts on how I should be formatting ‘$rank’ => [] in PHP?