MongoDB
 sql >> Base de Dados >  >> NoSQL >> MongoDB

Mongo $addToSet uma matriz


tente fazer isso,
$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'=>'$current_offense_literal', 'current_offense_literal_value' =>'$current_offense_literal_value']]]

                    ]
                ]);

            });