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
Percy14mo ago
Project ID: 6d443798-0942-4904-a7e4-89b7375c8bde
Alejandro Capra
Alejandro CapraOP14mo ago
6d443798-0942-4904-a7e4-89b7375c8bde
Fragly
Fragly14mo ago
I think you need to pass dbName in the connect options
Solution
Fragly
Fragly14mo ago
mongoose.connect(uri, {
dbName: "production",
...
})
mongoose.connect(uri, {
dbName: "production",
...
})
Alejandro Capra
Alejandro CapraOP14mo ago
Gonna try
Brody
Brody14mo ago
damn knew it off the top of his head
Fragly
Fragly14mo ago
<:glasses_3:1138999941361053726>
Brody
Brody14mo ago
here I was reading the docs so I could get a screenshot
No description
Brody
Brody14mo ago
just gonna mark, I know that's correct because it's in the docs and has worked times in the past
Want results from more Discord servers?
Add your server