V2 API for visualization gomathi part completed
This commit is contained in:
@@ -16,7 +16,7 @@ const MainModel = <T>(
|
||||
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
|
||||
authSource: process.env.MONGO_AUTH_DB || "admin", // Default to 'admin' if not provided
|
||||
maxPoolSize: 50,
|
||||
};
|
||||
|
||||
@@ -24,9 +24,9 @@ const MainModel = <T>(
|
||||
if (connections[db]) {
|
||||
return connections[db].model<T>(modelName, schema, collectionName);
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
const db1 = mongoose.createConnection(db1_url,authOptions);
|
||||
const db1 = mongoose.createConnection(db1_url, authOptions);
|
||||
|
||||
// Cache the connection
|
||||
connections[db] = db1;
|
||||
@@ -37,7 +37,10 @@ const MainModel = <T>(
|
||||
});
|
||||
|
||||
db1.on("error", (err) => {
|
||||
console.error(`MongoDB connection error for database ${db}:`, err.message);
|
||||
console.error(
|
||||
`MongoDB connection error for database ${db}:`,
|
||||
err.message
|
||||
);
|
||||
});
|
||||
|
||||
return db1.model<T>(modelName, schema, collectionName);
|
||||
@@ -48,4 +51,3 @@ const MainModel = <T>(
|
||||
};
|
||||
|
||||
export default MainModel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user