From 42b0cf61982264da7a7fad7c37c74a166fd98c5d Mon Sep 17 00:00:00 2001 From: Justin Hartman Date: Tue, 4 Jun 2024 02:30:51 +0200 Subject: [PATCH 1/2] fix: Fix error where DB connects to test DB incorrectly --- .gitignore | 1 + config/db.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0bf8131..1d61f44 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Configuration .env +CHANGELOG.md # Logs logs diff --git a/config/db.js b/config/db.js index 8753087..0f52eb8 100644 --- a/config/db.js +++ b/config/db.js @@ -17,8 +17,9 @@ const connectDB = async () => { /** * Attempts to connect to the MongoDB database using the provided URI. * @param {string} MONGO_DB_URI - The URI for the MongoDB database. + * @param {array} MONGO_DB_NAME - The name of the MongoDB database. */ - await mongoose.connect(appConfig.MONGO_DB_URI); + await mongoose.connect(appConfig.MONGO_DB_URI, { dbName: appConfig.MONGO_DB_NAME }); console.log('MongoDB Connected'); } catch (error) { /** From e1054ca297137ed28d1c2ff12a38d124d3e5a6e9 Mon Sep 17 00:00:00 2001 From: Justin Hartman Date: Tue, 4 Jun 2024 02:34:44 +0200 Subject: [PATCH 2/2] chore: Set mongoose to connect on IPV4 by default --- config/db.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/db.js b/config/db.js index 0f52eb8..1c714d5 100644 --- a/config/db.js +++ b/config/db.js @@ -17,9 +17,9 @@ const connectDB = async () => { /** * Attempts to connect to the MongoDB database using the provided URI. * @param {string} MONGO_DB_URI - The URI for the MongoDB database. - * @param {array} MONGO_DB_NAME - The name of the MongoDB database. + * @param {Object} options - The options for the MongoDB connection. */ - await mongoose.connect(appConfig.MONGO_DB_URI, { dbName: appConfig.MONGO_DB_NAME }); + await mongoose.connect(appConfig.MONGO_DB_URI, { dbName: appConfig.MONGO_DB_NAME, family: 4 }); console.log('MongoDB Connected'); } catch (error) { /**