Ich habe die folgende Abfrage in MongoDB arbeiten, aber es funktioniert nicht in PHP. MongoDB AbfrageConverting MongoDB Abfrage mit Aggregat zu PHP-Treiber Aggregat Abfrage
db.energy_meter.aggregate(
{
$unwind: {
path:"$KeyValues",
includeArrayIndex:"arrayIndex",
preserveNullAndEmptyArrays:true
}
},
{
$project: {
timestamp:{
"$add":["$EventTS",{"$multiply":[60000,"$arrayIndex"]}]
} ,
"RPhaseVoltage":"$KeyValues.RPhaseVoltage",
arrayIndex:1,
}
}
);
Above Abfrage in PHP umgewandelt wird
$cursor = DB::collection('energy_meter')->raw(function($collection)
{
return $collection->aggregate([
[
'$unwind' =>
['path' => '$KeyValues'],
['includeArrayIndex' => 'arrayIndex'],
['preserveNullAndEmptyArrays' => 'true']
],
[
'$project' =>
[
'timestamp' => [
'$add' => [
'$EventTS',
['$multiply' => [60000, '$arrayIndex']]
]
]
],
[
'MainsInputVoltagev' => ['$KeyValues.MainsInputVoltagev']
],
[
'arrayIndex' => 1
]
]
]);
});
Ich erhalte folgenden Fehler
RuntimeException in Aggregate.php line 168: A pipeline stage specification object must contain exactly one field.
Was Problem in meiner konvertierte php Abfrage ist? Bitte schlagen Sie die Lösung des obigen Problems vor.