payservedb 2.2.6 → 2.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -3
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -15,7 +15,7 @@ async function connectToMongoDB(dbName) {
|
|
|
15
15
|
// const authorization = "Ps:Letmein987@"
|
|
16
16
|
const connectionString = `mongodb://Ps:Letmein987@127.0.0.1:27017/${dbName}${source}`;
|
|
17
17
|
await mongoose.connect(connectionString, {
|
|
18
|
-
|
|
18
|
+
useNewUrlParser: true,
|
|
19
19
|
});
|
|
20
20
|
console.log('Connected to MongoDB');
|
|
21
21
|
} catch (err) {
|
|
@@ -31,10 +31,9 @@ async function switchDB(dbName) {
|
|
|
31
31
|
return connections[dbName]; // Return existing connection
|
|
32
32
|
}
|
|
33
33
|
try {
|
|
34
|
-
const connectionString = `mongodb
|
|
34
|
+
const connectionString = `mongodb://Ps:Letmein987@127.0.0.1:27017/${dbName}${source}`;
|
|
35
35
|
const dbConnection = await mongoose.createConnection(connectionString, {
|
|
36
36
|
useNewUrlParser: true,
|
|
37
|
-
useUnifiedTopology: true,
|
|
38
37
|
});
|
|
39
38
|
connections[dbName] = dbConnection; // Store the connection for reuse
|
|
40
39
|
console.log(`Switched to database: ${dbName}`);
|