MongoDB在Node中缺少一些方法

亚当·拉基斯(Adam Rackis)

我是Mongo的新手,似乎在使某些基本功能正常工作时遇到问题。

带注释的代码如下。它的短期是db.getCollectionNames没有定义,也db.foo.find()db.foos.find() 弹了出来,即使是从实际执行工作中的代码上市FOO集合。

我的mongo安装缺少某些功能吗?

var MongoClient = require('mongodb').MongoClient;

MongoClient.connect('mongodb://localhost:27017/mongotest', function(err, db){
    try {
        db.collections(function(e, cols) {
            cols.forEach(function(col) {
                console.log(col.collectionName); //WORKS just fine
            });
        });
        console.log(typeof db.getCollectionNames); //undefined

        //db.foos.find(); //[TypeError: Cannot call method 'find' of undefined]
        //db.foo.find(); //[TypeError: Cannot call method 'find' of undefined]
    } catch (ex) {
        console.log(ex);
    } finally {
        setTimeout(function(){ db.close(); }, 2000);
    }
});
香港强尼

看起来您可能在看Mongo Shell文档或旧版本的node.js本机驱动程序API。

在当前的2.x版本的驱动程序中,getCollectionNames已替换为listCollections

db.foo.find()语法而言,据我所知,本机驱动程序从未支持过语法。相反,它将是:

db.collection('foo').find()

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Calendar 类中缺少一些方法

来自分类Dev

JNA:缺少一些特定方法

来自分类Dev

缺少一些括号

来自分类Dev

DataGridView中缺少一些多对一的对象

来自分类Dev

JNA:缺少一些具体方法

来自分类Dev

在PHP中缺少一些CURL常量

来自分类Dev

范围中缺少一些JavaScript变量

来自分类Dev

PostgreSQL中缺少一些.dll文件

来自分类Dev

SublimeText-命令面板中缺少一些命令

来自分类Dev

Vaadin 在 Spring Boot 中缺少一些功能

来自分类Dev

Scrapy缺少一些html元素

来自分类Dev

Android BufferedReader缺少一些字母

来自分类Dev

缺少一些MFC标头

来自分类Dev

等待NodeJS中来自MongoDB的一些回调

来自分类Dev

kaa-node.log中的一些信息

来自分类Dev

Ubuntu 20.04中的GIMP 2.10中缺少一些流行的工具

来自分类Dev

Ubuntu 20.04中的GIMP 2.10中缺少一些流行的工具

来自分类Dev

V93k 测试方法参数类型缺少一些可接受的值?

来自分类Dev

重构Ruby on Rails中的一些模型方法

来自分类Dev

从Flutter的方法中获取一些变量值

来自分类Dev

从嵌套字典中删除一些键的优雅方法

来自分类Dev

在TestNG中的@BeforeMethod中排除一些方法

来自分类Dev

如何从Ruby中的模块中混合一些类方法和一些实例方法?

来自分类Dev

为什么wordcloud中缺少一些西里尔字母?

来自分类Dev

multer中间件内部req.body中缺少一些属性

来自分类Dev

在postgres中恢复转储后,缺少一些主键

来自分类Dev

在BigQuery中追加到缺少一些可空字段的目标表失败

来自分类Dev

联系人在ios中缺少一些必需的键描述符

来自分类Dev

在ggplot2中绘制时缺少一些sf多边形