0
以下のクエリはmongoDBで動作しますが、PHPでは動作しません。 MongoDBのクエリクエリの上アグリゲートからPHPドライバへの集約クエリを使用したMongoDBクエリの変換
db.energy_meter.aggregate(
{
$unwind: {
path:"$KeyValues",
includeArrayIndex:"arrayIndex",
preserveNullAndEmptyArrays:true
}
},
{
$project: {
timestamp:{
"$add":["$EventTS",{"$multiply":[60000,"$arrayIndex"]}]
} ,
"RPhaseVoltage":"$KeyValues.RPhaseVoltage",
arrayIndex:1,
}
}
);
が、私は次のようなエラーに
RuntimeException in Aggregate.php line 168: A pipeline stage specification object must contain exactly one field.
を取得していますPHP
$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
]
]
]);
});
に変換され、私の変換PHPのクエリでの問題は何ですか?上記の問題の解決を提案してください。