By Pak
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!
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 database exampleDB:
DATABASE_URL="mongodb+srv://doadmin:password@clusterName-eddb9489.mongo.ondigitalocean.com/exampleDB?tls=true"
Let me know how it goes!
- Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.