payservedb 5.3.5 → 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
|
-
|
|
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,3 +1,5 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
1
3
|
const pendingCredentialSchema = new mongoose.Schema({
|
|
2
4
|
userId: {
|
|
3
5
|
type: mongoose.Schema.Types.ObjectId,
|
|
@@ -25,5 +27,7 @@ const pendingCredentialSchema = new mongoose.Schema({
|
|
|
25
27
|
expires: '7d' // Auto-delete after 7 days
|
|
26
28
|
}
|
|
27
29
|
});
|
|
30
|
+
|
|
31
|
+
const PendingCredential = mongoose.model("PendingCredential", pendingCredentialSchema);
|
|
28
32
|
|
|
29
|
-
module.exports =
|
|
33
|
+
module.exports = PendingCredential;
|
|
File without changes
|