我有一个查询,查询依据:
$offenses = \App\LawCase::raw(function ($collection) {
return $collection->aggregate([
[
'$match' => ['active' => true, 'type' => 'criminal', 'current_offense_literal'=> ['$exists' => true]]
],
[
'$group' => ['_id' => '$current_offense_category',
'offense_literals' => ['$addToSet' => '$current_offense_literal'], 'code'=> ['$addToSet' => '$current_offense'], 'count' => ['$sum' => 1]]
]
]);
});
它工作正常,但我想获得上面出现的特定“ current_offense_literal”的出现次数。我猜一个小组中的一个小组?