Where do I put the database name in my connection string? Using serverlessaws.

using: mongodb+srv://:@serverlessaws.onx2ah0.mongodb.net/?retryWrites=true&w=majority&appName=ServerlessAWS

No matter what I try (i.e. at the end of the string), it only connects to test database. Trying to connect to specific db (i.e. xyz)

Add like here
/dbname?
Check options parameter for connect string in mongo documentation

1 Like

Hi David, here is the documentation for where to add a specific DB in the connection string URI: https://www.mongodb.com/docs/v5.2/reference/connection-string/#components

Out of curiosity, is there a reason why you were trying the appName parameter?

Also, I want to ensure you’re aware that once you establish a client connection with the connection string, you can access specific DBs from the single connection. This is a best practice for good performance: https://www.mongodb.com/docs/manual/administration/connection-pool-overview/#use-an-instance-of-your-driver-s-mongoclient-object.