繁体   English   中英

使用Monk在MongoDB中列出集合名称

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM