如何在Mongo的小组中进行小组?

时间:2018-12-06 16:29:04

标签: php mongodb aggregation-framework

我有一个查询,查询依据:

 $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”的出现次数。我猜一个小组中的一个小组?

0 个答案:

没有答案