正确的连接方法。日志中不支持的警告

时间:2019-01-23 18:12:42

标签: node.js mongodb

我试图找出使用本机驱动程序版本3.10和Mongodb Server版本3.6.5连接到Nodejs中mongodb的正确方法

我通读了提供了不同方法的文档,每种文档都产生类似的警告。所有这些方法都可以使用,但是与数据库的每个连接所伴随的警告使调试查询和其他代码问题变得更加困难。

我的连接代码是:

const MongoClient = require('mongodb').MongoClient
const url = `mongodb://${process.env.MONGO_HOST}:${process.env.MONGO_PORT}`
const opts = {
    useNewUrlParser: true,
    authMechanism: process.env.MONGO_MECH,
    authSource: process.env.MONGO_SRC,
    auth: {
        user: process.env.MONGO_USER,
        password: process.env.MONGO_PWD
    }
}
const Client = new MongoClient(url, opts)

此代码在日志中给出以下消息,并对数据库执行所有操作

the options [socketOptions] is not supported
the options [read_preference_tags] is not supported
the options [dbName] is not supported
the options [servers] is not supported
the options [server_options] is not supported
the options [db_options] is not supported
the options [rs_options] is not supported
the options [mongos_options] is not supported
the options [mode] is not supported
the options [tags] is not supported
the options [preference] is not supported
the options [isValid] is not supported
the options [slaveOk] is not supported
the options [equals] is not supported
the options [toJSON] is not supported

0 个答案:

没有答案