I have a Mongo DB query which needs to convert using MongoEngine. consider below query and I wanted to implement the same in MongoEngine ORM. I'm very much new to MongoDB and MongoEngine. thanks in advance
db.my_collection.aggregate([
{
$unwind:"$quizzes"
},
{
$group:{
"_id":"$quizzes.skill",
"k":{
$first:"$quizzes.skill"
},
"v":{
$sum:1
}
}
},
{
$project:{
"_id":0
}
},
{
$group:{
"_id":null,
"data":{
$push:"$$ROOT"
}
}
},
{
$project:{
"data":{
$arrayToObject:"$data"
}
}
},
{
$replaceRoot:{
"newRoot":"$data"
}
}
]).pretty()
the above mongo query will give following result
{ "skill1": 40, "skill2": 50, "skill3": 23, . . . . . . . }
I wanted to have the same result. but the implementation should be from MongoEngine ORM.