使用 prisma 连接我的 mongo 数据库时出错

问题描述 投票:0回答:1

创建架构后,我点击 npx prisma generated 然后我点击 npx prisma db push 然后它给我以下错误请帮助... 提供的数据库字符串无效。提供的参数无效:必须在数据库 URL 的连接字符串中定义数据库。请参阅 https://www.prisma.io/docs/reference/database-reference/connection-urls 中的文档来构建正确的连接字符串。在某些情况下,某些字符必须进行转义。请检查字符串是否有非法字符。

我试图推送我的 mongodb

以下是我的 mongodb url mongodb+srv://pramitinps:[电子邮件受保护]/?retryWrites=true&w=majority

mongodb database-connection prisma
1个回答
0
投票

包含您要连接的数据库的名称。

例如,如果您的数据库名为 superhero 那么您的连接将包含它,如下所示:

mongodb+srv://pramitinps:[email protected]/superhero?retryWrites=true&w=majority

使用 MongoDB Atlas,请始终遵循以下格式:

mongodb+srv://<username>:<password>@<clusterName>.mongodb.net/<dbname>?retryWrites=true&w=majority

其中

<username>
<password>
<clusterName>
<dbname>
是您的特定连接的占位符。

© www.soinside.com 2019 - 2024. All rights reserved.