-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
27 lines (23 loc) · 848 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
const Sequelize = require("sequelize");
const POSTGRES_CONNECTION_STRING = process.env.POSTGRES_CONNECTION_STRING || "postgres://postgres:password@localhost:6432/postgres";
function performValidation(order){
return true;
}
async function validateOrder(order) {
try {
var sequelize = new Sequelize(
POSTGRES_CONNECTION_STRING, {}
);
var isValid = performValidation(order);
var res = await sequelize.query('UPDATE orders SET order_valid = :isValid WHERE order_id = :orderId',
{ replacements: { isValid: isValid, orderId: order.order_id } }
);
return res;
} catch(e) {
console.log(e);
throw new Error(e);
} finally {
sequelize.close();
}
}
exports.validateOrder = validateOrder;