payservedb 5.3.6 → 5.3.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 CHANGED
@@ -40,11 +40,20 @@ async function switchDB(dbName) {
40
40
  if (connections[dbName]) {
41
41
  return connections[dbName]; // Return existing connection
42
42
  }
43
+
43
44
  try {
44
- const connectionString = `mongodb://${url}/${dbName}${source}`;
45
+ // Use environment variables for connection parameters - same as in connectToMongoDB
46
+ const username = process.env.MONGODB_USER;
47
+ const password = process.env.MONGODB_PASSWORD;
48
+ const url = process.env.MONGODB_HOST;
49
+ const port = process.env.MONGODB_PORT;
50
+ const source = '?authSource=admin';
51
+
52
+ const connectionString = `mongodb://${username}:${password}@${url}:${port}/${dbName}${source}`;
45
53
  const dbConnection = await mongoose.createConnection(connectionString, {
46
54
  useNewUrlParser: true,
47
55
  });
56
+
48
57
  connections[dbName] = dbConnection; // Store the connection for reuse
49
58
  console.log(`Switched to database: ${dbName}`);
50
59
  return dbConnection;
@@ -130,6 +139,8 @@ const models = {
130
139
  SingleDayWaterMeterHistory: require('./src/models/water_meter_single_day_history'),
131
140
  DailyWaterMeterHistory: require('./src/models/water_meter_daily_history'),
132
141
  MonthlyWaterMeterHistory: require('./src/models/water_meter_monthly_history'),
142
+ WaterPrepaidCredit: require('./src/models/water_prepaid_credit'),
143
+ WaterPrepaidDebit: require('./src/models/water_prepaid_debit'),
133
144
  MeterLog: require('./src/models/water_meter_communication_logs'),
134
145
  CashPayment: require('./src/models/cashpayment'),
135
146
  VasPayment: require('./src/models/vas_payments'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payservedb",
3
- "version": "5.3.6",
3
+ "version": "5.3.7",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"