Keyv + MongoDb TypeError “id”参数必须是字符串类型。收到未定义

时间:2021-04-24 19:45:30

标签: node.js mongodb keyv

我在使用 KeyvKeyv/mongo 时遇到此 TypeError。

throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received undefined

尝试创建 Keyv 的新实例时,我按照指示传入连接字符串。

来自 MongoDB Atlas 的给定字符串模板 MongoDB Atlas' Given Connection String Template

传递连接字符串的 Keyv 文档示例 Keyv Documentation Example Connection String Example


这是我的代码,我已按照指示将密码和数据库名称插入给定的连接字符串中。

const Keyv = require('keyv');
const keyv = new Keyv('mongodb+srv://Elitezen4531:***********@zen.hjg40.mongodb.net/Discord_Zen_Bot?retryWrites=true&w=majority');

keyv.on('error', err => console.error('Keyv connection error:', err));

0 个答案:

没有答案