[英]How to get a list of items from a mongodb collection using monk and node
[英]List Collection Names in MongoDB using Monk
在我使用Monk的Node.js(Express)應用程序中,我需要呈現MongoDB數據庫中所有集合的列表。
有沒有辦法使用Monk獲取數據庫中的集合列表?
這將基本上做到這一點,但它需要深入挖掘潛在的驅動程序:
var db = require('monk')('localhost/test');
db.on("open",function() {
console.log(
db.driver._native.command(
{ "listCollections": 1 },
function(err,result) {
console.log( result.cursor.firstBatch.map(function(el) {
return el.name;
}))
}
)
);
});
驅動程序命令當然是“listCollections” ,這些是你需要跳過才能到達那里的基本箍
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.