-
Notifications
You must be signed in to change notification settings - Fork 3
/
update-feature-list.js
27 lines (24 loc) · 1020 Bytes
/
update-feature-list.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 updateFeatureList = (unitId, featureList, connection) => {
const numOfRooms = JSON.stringify(featureList.numOfRooms);
const parking = JSON.stringify(featureList.parking);
const smoking = JSON.stringify(featureList.smoking);
const pets = JSON.stringify(featureList.pets);
const postedDate = JSON.stringify(new Date().toISOString());
const sql = `UPDATE feature_list
SET number_of_rooms = ${numOfRooms},
parking = ${parking},
smoking = ${smoking},
pets = ${pets},
posted_date = ${postedDate}
WHERE unit_id = ${JSON.stringify(unitId)}`;
return new Promise((resolve, reject) => {
connection.query(sql, function (err, result) {
if (err) reject(err);
else {
resolve();
console.log(`Success: Updated feature list to rental unit - ${unitId}`);
}
});
})
}
module.exports = updateFeatureList