您的位置:首頁技術文章
文章詳情頁

javascript - mongoose 如何獲得所有collection

瀏覽:135日期:2024-03-28 13:07:27

問題描述

我需要統計數據里所有的collection,哪個collection包含最多的數據,請問該如何處理??吹降膍ongoose都是用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
相關文章:
国产综合久久一区二区三区