您的位置:首页技术文章
文章详情页

javascript - mongoose 如何获得所有collection

【字号: 日期:2024-03-28 13:07:27浏览:87作者:猪猪

问题描述

我需要统计数据里所有的collection,哪个collection包含最多的数据,请问该如何处理。看到的mongoose都是用model来处理对应的collection,那数据库里有已经导入的大量数据,我该如何获得collection?

问题解答

回答1:

获得collections的列表:

1、使用node-mongodb-native驱动的listCollections

http://mongodb.github.io/node...

2、Mongoose中的connection也继承了上述原生驱动:

https://github.com/Automattic...

mongoose.connection.db.listCollections()

包含数量最多的Collection:

需要自己来统计和排序

供参考。

Love MongoDB!Have fun!

回答2:

show tables

标签: JavaScript
相关文章: