1、查询统计总数:
db.getCollection("student").count();
2、查询统计根据某个字段去重后的总数:
db.getCollection("student").distinct("name").length;
本文介绍了如何在MongoDB中使用`db.getCollection()`方法进行查询统计,包括计算集合的总数以及根据特定字段去重后的数量。
1、查询统计总数:
db.getCollection("student").count();
2、查询统计根据某个字段去重后的总数:
db.getCollection("student").distinct("name").length;
6237
899
1648
618

被折叠的 条评论
为什么被折叠?
