我的 mongodb 客户集合具有以下字段:
{
"_id" : ObjectId("582577eebac0ef176a8d0697"),
"customerID" : NumberLong(37620089),
"storeID" : NumberLong(1),
"updatedDate" : ISODate("2017-03-27T14:07:11.278Z"),
"customerName" : "hsingla cust"
}
我想运行 2 个查询,这些查询在 SQL 中如下所示:
Select * from Customer group by customerID having storeID=1;
Select count(*) from Customer group by customerID having storeID=1;
我是 mongodb 的新手,我已经阅读了各种文章,但似乎无法得到正确的答案。
另外,我mongoTemplate
在 java 中使用,所以如果您可以使用mongoTemplate
.