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
Percy13mo ago
Project ID: 6d443798-0942-4904-a7e4-89b7375c8bde
Alejandro Capra
Alejandro Capra13mo ago
6d443798-0942-4904-a7e4-89b7375c8bde
Fragly
Fragly13mo ago
I think you need to pass dbName in the connect options
Solution
Fragly
Fragly13mo ago
mongoose.connect(uri, {
dbName: "production",
...
})
mongoose.connect(uri, {
dbName: "production",
...
})
Alejandro Capra
Alejandro Capra13mo ago
Gonna try
Brody
Brody13mo ago
damn knew it off the top of his head
Fragly
Fragly13mo ago
<:glasses_3:1138999941361053726>
Brody
Brody13mo ago
here I was reading the docs so I could get a screenshot
No description
Brody
Brody13mo 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