您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何设置useMongoClient(Mongoose 4.11.0)?

如何设置useMongoClient(Mongoose 4.11.0)?

您几乎可以忽略该问题并使用Mongoose.connect(databaseUri, { useMongoClient: true })

如果您确实想避免出现警告,请避免使用4.11.0版本。

我更新到4.11.1版本,因为@类型/猫鼬@尚未进行更新4.7.18和他们不提现场useMongoClientConnectionOptions,我这是怎么导入模块:

const Mongoose = require('mongoose');

然后用了这个功能

private connectDatabase(databaseUri: string): Promise<any> {
    return Mongoose.connect(databaseUri, { useMongoClient: true })
        .then(() => {
            console.log('Connected to MongoDB at ', databaseUri);
            return Mongoose.connection;
        })
        .catch(err => debug(`Database connection error: ${err.message}`));
}
mongodb 2022/1/1 18:15:20 有259人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶