Anda harus menggunakan kueri berikut:
db.collection.aggregate({
$group: {
_id: "$threadId",
"records": {
$push: "$$ROOT"
},
"count": {
$sum: 1
}
}
}).pretty()
Jika Anda ingin menambahkan match
kriteria kemudian gunakan kueri berikut -
db.collection.aggregate({
$match: {
"poiId": "538318500cf2e33469a2d819" //can change match parameters
}
}, {
$group: {
_id: "$threadId",
"records": {
$push: "$$ROOT"
},
"count": {
$sum: 1
}
}
}).pretty()