我正在尝试使用以下mongoDB查询与Laravel Jessanger,但无法将其作为raw
查询运行。
db.getCollection('users').aggregate([
{
"$group": {
"_id": { "cnic": "$cnic", "time_in": "$time_in" },
"uniqueIds": { "$addToSet": "$_id" },
"count": { "$sum": 1 }
}
},
{ "$match": { "count": { "$gt": 1 } } }
]).forEach(function(doc) {
doc.uniqueIds.shift();
db.getCollection('users').remove({_id : {$in: doc.uniqueIds }});
})
我希望直接运行这个查询以从数据库中删除重复项。
我尝试使用以下方式:
Users::raw()->find('mongo raw statement')
并且
$cursor = DB::collection('users')->raw(function($collection)
{
return $collection->find('mongo raw statement');
});
谢谢