-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
33 lines (30 loc) · 869 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
29
30
31
32
33
const server = require('./backend/server.js');
const dbutils = require('./database/dbutils.js');
dbutils.runMigrate((error) => {
if (error) {
throw error
}
const query = 'SELECT * FROM trip order by trip_id desc limit $1;';
const data = ['1']
dbutils.runQuery(query, data, (err, result) => {
if (result.rowCount > 0) {
// eslint-disable-next-line no-console
console.log('there is data in table so you cant use sequence');
} else {
dbutils.runSequence((err, result1) => {
if (err) {
// eslint-disable-next-line no-console
console.log('errr in sequencr:', err);
return;
}
})
}
server.start((error) => {
if (error) {
throw error
}
// eslint-disable-next-line no-console
console.log('Server running at:' + server.info.uri)
})
})
})