🔧 refactor: Make MongoDB name optional in connection options

This commit is contained in:
Ruben Talstra 2025-05-29 16:21:52 +02:00
parent d7f4f8ef4a
commit cffd66054e
No known key found for this signature in database
GPG key ID: 2A5A7174A60F3BEA
2 changed files with 5 additions and 2 deletions

View file

@ -27,7 +27,6 @@ async function connectDb() {
if (!cached.promise || disconnected) {
const opts = {
bufferCommands: false,
dbName: MONGO_DB_NAME,
// useNewUrlParser: true,
// useUnifiedTopology: true,
// bufferMaxEntries: 0,
@ -35,6 +34,10 @@ async function connectDb() {
// useCreateIndex: true
};
if (MONGO_DB_NAME) {
opts.dbName = MONGO_DB_NAME;
}
mongoose.set('strictQuery', true);
cached.promise = mongoose.connect(MONGO_URI, opts).then((mongoose) => {
return mongoose;