node.js - 正确的连接方法。日志中不支持的警告
问题描述
我正在尝试找出使用本机驱动程序版本 3.10 和 Mongodb 服务器版本 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
解决方案
推荐阅读
- python-3.x - 是他们的 SDK 库在 python 中创建 Github Bot
- python - 是否可以将matlab fitnet神经网络转换为keras
- mysql - 优化 mySQL 查询以更好地扩展
- aws-glue - Athena 没有看到新的每日分区文件夹
- image - 在没有 ui 的情况下在 Flutter 中裁剪和保存图像
- caching - Varnish Cache 4.1 行为怪异 - 缓存我的登录页面一次然后不再缓存 - VCL 代码
- mysql - 如何使用 LAG 从 MYSQL 表中获取最后一个非空值
- angular - Angular - 将应用名称添加到您的 Angular 应用 url
- javascript - 如何在所有 Vue3 组件中设置反应式语言环境?
- powershell - 每当我在项目文件夹中启动 Powershell 会话时,如何激活 conda 环境?