Testing failer uncomment issue sorted API-Docker updated based on the Failed testcase
This commit is contained in:
@@ -14,13 +14,12 @@ const MainModel = <T>(
|
||||
): Model<T> => {
|
||||
const db1_url = `${process.env.MONGO_URI}${db}`;
|
||||
const authOptions = {
|
||||
user: process.env.MONGO_USER, // Correct username environment variable
|
||||
pass: process.env.MONGO_PASSWORD, // Correct password environment variable
|
||||
authSource: process.env.MONGO_AUTH_DB || "admin", // Default to 'admin' if not provided
|
||||
user: process.env.MONGO_USER,
|
||||
pass: process.env.MONGO_PASSWORD,
|
||||
authSource: process.env.MONGO_AUTH_DB || "admin",
|
||||
maxPoolSize: 50,
|
||||
};
|
||||
|
||||
// Check if the connection already exists
|
||||
if (connections[db]) {
|
||||
return connections[db].model<T>(modelName, schema, collectionName);
|
||||
}
|
||||
@@ -28,10 +27,8 @@ const MainModel = <T>(
|
||||
try {
|
||||
const db1 = mongoose.createConnection(db1_url, authOptions);
|
||||
|
||||
// Cache the connection
|
||||
connections[db] = db1;
|
||||
|
||||
// Log connection success or handle errors
|
||||
db1.on("connected", () => {
|
||||
console.log(`Connected to MongoDB database: ${db}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user