
mongondb
_陌子曦
java开发
展开
-
springboot mongdb 聚合操作记录
1.数据集合如下所示 { "_id" : ObjectId("61b0ba42ad73bc04fc538bdq”), "userId" : "61af93b3ad73bc04fc538b21”, “schoolName”:”北京大学”, "status" : 1, "createTime" : ISODate("2021-12-08T13:59:20.495Z"), "updateTime" : ISODate("2021-12-08T14:44:16.213Z"), "delete" :原创 2021-12-09 15:09:30 · 483 阅读 · 0 评论 -
mongodb 聚合分组(aggregate group) 之后想要查询出来多个字段,如何实现?例子里面都是只有_id跟另外一个聚合结果?
MongoDB语句实现如下: db.myexcel.aggregate([ { "$group": { "_id": { "area": "$area", "name": "$name", "age": "$age" }, "totalFormalNumber": { "$sum": { "$toDouble": "$FormalNumber"原创 2020-06-04 08:18:45 · 6671 阅读 · 0 评论 -
mongo聚合之后求和,求和的字段是string类型怎么解决(java方式和mongodb命令方式)
mongodb命令方式: db.myexcel.aggregate([ { "$group": { "_id": null, "totalFormalNumber": { "$sum": { "$toDouble": "$FormalNumber" } }, "count": { "$sum": 1 } } } ]) 结果: { .原创 2020-06-03 11:51:52 · 3123 阅读 · 2 评论