azure宇宙数据库'=';连接字符串在mongoose中失败。连接(…)

azure宇宙数据库'=';连接字符串在mongoose中失败。连接(…),mongoose,azure-cosmosdb,Mongoose,Azure Cosmosdb,Nodejs脚本: MongoError: database name must be a string 如果我删除==或%3D%3D,或更改为其他内容(例如XX),则错误为预期错误: // Azure tells me to use mongodb://mydb:LONG-STRING-ENDING-WITH==@mydb.documents.azure.com:10255/?ssl=true // I change the = to %3D - I've confirmed this is

Nodejs脚本:

MongoError: database name must be a string
如果我删除
==
%3D%3D
,或更改为其他内容(例如XX),则错误为预期错误:

// Azure tells me to use mongodb://mydb:LONG-STRING-ENDING-WITH==@mydb.documents.azure.com:10255/?ssl=true
// I change the = to %3D - I've confirmed this is the correct escaping
readonly serverConnection = 'mongodb://mydb:LONG-STRING-ENDING-WITH%3D%3D@mydb.documents.azure.com:10255/?ssl=true');

...
const mongoDB = await mongoose.connect(
    this.serverConnection,
    {
      useNewUrlParser: true,
      reconnectTries: Number.MAX_VALUE,
      reconnectInterval: 1000
    }
  );
所以它不是字符串的长度,必须是==


为什么会这样?你能做些什么来回避这个问题呢?

我找到了部分答案。删除以下内容:

{ MongoError: Authentication Failed
忽略警告。现在。它告诉您这个解决方案在将来某个时候不会起作用

useNewUrlParser: true

如果有人能详细介绍如何在连接字符串中使用新解析器和
=
,我将不胜感激。另外,如果您知道为什么会出现
==
或转义版本的问题,那就太好了。

我找到了一个很好的答案,您不必放弃新的url解析器。必须在连接字符串的末尾添加数据库名称,如下所示:

DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
mongodb://:port/?ssl=True

在我看来,这是一个干净的解决方案。我希望我能帮上忙

我遇到了同样的问题。。。我从azure portal复制了节点的显式连接字符串,但它不起作用。我希望有人能解释为什么会发生这种情况!
mongodb://<connectionstring/url>:port/<DATABASENAME>?ssl=True