javascript - mongoose 如何获得所有collection
PHP中文网
PHP中文网 2017-05-17 10:03:06
0
2
662

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

PHP中文网
PHP中文网

认证高级PHP讲师

全部回复(2)
phpcn_u1582

获得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!

给我你的怀抱

显示表格

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!