Hello, I created a Cluster Database (with mongoDB) in digitalOcean then created a new database collection “exampleDB” . In the other side, nextJS project (with prisma) I put the url to connect to my Cluster Database.
So I have 2 cases, the first one, it’s ok and all data from my project NextJS are going to admin file (default file created when we create a cluster) but now I want to put my data from nextJS to a specific file, in exampleDB but it doesn’t work! :(
Case 1:
DATABASE_URL="mongodb+srv://doadmin:password@clusterName-eddb9489.mongo.ondigitalocean.com/admin?tls=true"
Case 2:
DATABASE_URL="mongodb+srv://doadmin:password@clusterName-eddb9489.mongo.ondigitalocean.com/admin?tls=true/exampleDB"
My trouble is with the DATABASE_URL
, in the case 2, I have this error:
Error: P1013
The provided database string is invalid. An invalid argument was provided: connection string tls
option must be a boolean in database URL. Please refer to the documentation in https://www.prisma.io/docs/reference/database-reference/connection-urls for constructing a correct connection string. In some cases, certain characters must be escaped. Please check the string for any illegal characters.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey!
In MongoDB connection strings, the database name should be specified directly after the hostname, and query parameters (like
tls
) should be correctly formatted. Here’s how you can adjust your connection string for your specific databaseexampleDB
:Let me know how it goes!
- Bobby