Test
This commit is contained in:
parent
2c41222aa3
commit
11ccdefa2b
|
@ -57,11 +57,13 @@ router.put('/', async (req, res) => { // Attempt to create new ACL entry. Fail i
|
|||
data.StartDate || new Date(),
|
||||
data.EndDate || new Date(new Date().setFullYear(new Date().getFullYear() + 99))
|
||||
];
|
||||
data.doors.forEach(door => {
|
||||
fields.push(door);
|
||||
placeholders.push('?');
|
||||
values.push(1);
|
||||
});
|
||||
for (const door in data.doors) {
|
||||
if (data.doors.hasOwnProperty(door)) {
|
||||
fields.push(door);
|
||||
placeholders.push('?');
|
||||
values.push(data.doors[door] ? 1 : 0);
|
||||
}
|
||||
}
|
||||
const sql = `INSERT INTO ACL (${fields.join(', ')}) VALUES (${placeholders.join(', ')})`;
|
||||
db.query(sql, values).then(result => {
|
||||
return res.status(201).json({ message: 'ACL entry created' });
|
||||
|
|
Loading…
Reference in a new issue