payservedb 2.2.5 → 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.
Files changed (2) hide show
  1. package/index.js +3 -4
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -6,7 +6,7 @@ const WaterConcentrator = require('./src/models/waterConcentrator');
6
6
  // Maintain a record of open connections for each database
7
7
  const connections = {};
8
8
  const url = '127.0.0.1:27017';
9
- const source = process.env.source
9
+ const source = '?authSource=admin'
10
10
 
11
11
  // Utility function to connect to MongoDB
12
12
  async function connectToMongoDB(dbName) {
@@ -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
- useUnifiedTopology: true,
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://${url}/${dbName}${source}`;
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}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "2.2.5",
3
+ "version": "2.2.7",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"