у меня есть данные
{
"_id": {
"$oid": "5e8e1be5a78b4479443eae43"
},
"vehicle_component_id": 3,
"damages_types": [
1,
7
],
"mileages": [
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0"
],
"damages": {
"1": {
"upper_bound": [
null
],
"damages": [
"0"
],
"lower_bound": [
null
]
},
"7": {
"upper_bound": [
null
],
"damages": [
"0"
],
"lower_bound": [
null
]
}
},
"created_at": "2020-04-08 20:45:57",
"updated_at": "2020-04-08 20:45:57"
}
и при попытке получить размер или длину массива mileages запрос mon go равен
db.vehicle_component_damages_values.aggregate(
{ $match: { vehicle_component_id: 3} },
{$project: { count: { $size:"$mileages" }}}
)
, и он возвращает 10, как и ожидалось но при попытке с jenssegers / laravel -mongodb вроде
$query = DB::connection($this->mongoCon)->collection($this->table)->raw(function($collection) use ($vehicleComponentId) {
return $collection->aggregate([
['$match' => ['vehicle_component_id' => $vehicleComponentId]],
[
'$project' => [
'count' => [
'$size' => '$mileages'
]
]
],
]);
});
возвращается
MongoDB\Driver\Cursor {#550}