mongodb - MongoDb 连接字符串问题 - retryWrites Expected stringified boolean value
问题描述
我在连接到 mongoDB 的 Atlas 集群时遇到问题。
如果我尝试获取一些数据,它会返回一个错误
“在副本集配置中找不到名为‘majority’的写入关注模式”
我查看了错误,每个人都说要删除&w=majority
连接字符串末尾的 。
这样做了,但现在我面临一个新错误
UnhandledPromiseRejectionWarning: MongoParseError: For retryWrites Expected stringified boolean value, got: true
我没有以任何方式修改字符串,它昨天还在工作。
我的字符串是
mongodb+srv://username:password@cluster0.yummd.mongodb.net/dbName?retryWrites=true&w=majority
字符串末尾没有空格或任何东西,不知道它是什么。
有什么帮助吗?
解决方案
我有同样的问题,并遇到了你的帖子。我发现我的连接中的问题是我有双引号和单引号"'mongodb+srv://username:password@database.aaaa.mongodb.net/collection?retryWrites=true&w=majority'"
。所以简单的解决方案就是删除单引号。这为我解决了这个问题。然后你得到:"mongodb+srv://username:password@database.aaaa.mongodb.net/collection?retryWrites=true&w=majority"
我不知道你是否已经解决了它,但也许你还没有。
推荐阅读
- git - 我从服务器上的 github 克隆我的项目时出错
- discord.js - 尝试执行一个不带前缀的 Discord.js 命令
- android - 如何通过后退按钮(箭头)将活动导航到片段?
- c - 拓扑排序 - 创建直接图问题
- c++ - 如何将 jbyteArray(或字节数组)写入 txt 文件 c++?
- ssh - Jsch - 在到 SLES15 服务器的单个会话中打开多个通道失败
- excel - 返回值表示 Excel 中的最小值
- git - git extract directory from repository - 重命名之前的提交历史丢失
- css - 具有透明背景的文本的 CSS 视频在 Safari 上不起作用
- wordpress - Wordpress localhost:3000 使用 MAMP 6 返回 SSL_ERROR_RX_RECORD_TOO_LONG