MONGO DB database

Hello, I want to connect my project with mongodb, but currently I can only connect to the "test" database and I want to create one called production, but I can't This is my url to connect to mongo : mongodb://mongo:********@containers-zone.railway.app:PORT but if i try mongodb://mongo:********@containers-zone.railway.app:PORT/production it does not work
//With railway or env
const uri = process.env.MONGO_URL;

mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const port = process.env.PORT || 3001;


app.listen(port, "0.0.0.0", () => {
console.log(`Server started at port ${port}`);
});
//With railway or env
const uri = process.env.MONGO_URL;

mongoose.connect(uri, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
const port = process.env.PORT || 3001;


app.listen(port, "0.0.0.0", () => {
console.log(`Server started at port ${port}`);
});
Solution:
```js mongoose.connect(uri, { dbName: "production", ... })...
Jump to solution
9 Replies
Percy
Percy8mo ago
Project ID: 6d443798-0942-4904-a7e4-89b7375c8bde
Alejandro Capra
Alejandro Capra8mo ago
6d443798-0942-4904-a7e4-89b7375c8bde
Fragly
Fragly8mo ago
I think you need to pass dbName in the connect options
Solution
Fragly
Fragly8mo ago
mongoose.connect(uri, {
dbName: "production",
...
})
mongoose.connect(uri, {
dbName: "production",
...
})
Alejandro Capra
Alejandro Capra8mo ago
Gonna try
Brody
Brody8mo ago
damn knew it off the top of his head
Fragly
Fragly8mo ago
<:glasses_3:1138999941361053726>
Brody
Brody8mo ago
here I was reading the docs so I could get a screenshot
No description
Brody
Brody8mo ago
just gonna mark, I know that's correct because it's in the docs and has worked times in the past