-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (23 loc) · 910 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const mongoose = require('mongoose');
const { calculateDriverSalary, calculateRevenue, checkBusMaintenance } = require('./functions'); // Import các hàm từ file khác nếu bạn tách ra
const { connectionString } = require('./appConfig')
mongoose.connect(connectionString)
.then(() => {
console.log('Connected to MongoDB');
runFunctions();
})
.catch(err => console.error('Error connecting to MongoDB', err));
async function runFunctions() {
try {
console.log("\n-----------------Yêu cầu 1: ------------------\n")
await calculateDriverSalary();
console.log("\n-----------------Yêu cầu 2: ------------------\n")
await calculateRevenue('2024-09-01', '2024-09-30');
console.log("\n-----------------Yêu cầu 3: ------------------\n")
await checkBusMaintenance();
} catch (error) {
console.error(error);
} finally {
mongoose.disconnect();
}
}