【发布时间】:2019-02-10 01:49:55
【问题描述】:
大家好。我有想要分组的示例数据。
{
"_id" : ObjectId("5b8de8e635da281e1cb6279b"),
"CountryName" : "Spain",
"SmartClassification": "Special Focus"
}
{
"_id" : ObjectId("5b8de8e635da281e1cb6279c"),
"CountryName" : "Malaysia",
"SmartClassification": "Investment Focus"
}
{
"_id" : ObjectId("5b8de8e635da281e1cb6279c"),
"CountryName" : "Nigeria",
"SmartClassification": "Fundamental Focus"
}
我想按“CountryName”及其“SmartClassifications”的总数对上面的数据进行$group。这对我来说很棘手,因为我对 MongoDB 比较陌生。如何重现上面的插图?
【问题讨论】:
标签: javascript node.js mongodb mongoose aggregation-framework