Vote count:
0
Each document in my collection has a property that is an array and that array has objects with properties such as total, index, etc. I want to group the documents by the sum of the total property of the second array element, like the query below. How Can i make it happen?
db.collection.aggregate([{$project:{},{$match:{}, {"$group":{_id:null,total:{$sum:"$myarray[1].total"}}}])
asked 2 mins ago
Group query in mongoDB using array items to calculate sum
Aucun commentaire:
Enregistrer un commentaire