要查询 MongoDB 中的记录数,可以使用以下方法之一:
count() 方法:db.collectionName.count()
countDocuments() 方法(推荐):db.collectionName.countDocuments()
这两种方法都可以用来获取指定集合中的记录数。请记住,MongoDB 从版本 4.0 开始,count() 方法已被弃用,建议使用 countDocuments() 方法。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: pycharm卸载mongodb的方法是什么