fix: use Promise.all instead await

This commit is contained in:
Nikola Ubavic 2021-10-27 19:05:53 +02:00
parent 30ac3d61be
commit 5b3c71822e

View file

@ -14,11 +14,12 @@ function pullToken (token) {
function unpair (deviceId) { function unpair (deviceId) {
// TODO new-admin: We should remove all configs related to that device. This can get tricky. // TODO new-admin: We should remove all configs related to that device. This can get tricky.
return db.tx(async t => { return db.tx(t => {
await t.none('DELETE FROM devices WHERE device_id=$1', [deviceId]) const q1 = t.none('DELETE FROM devices WHERE device_id=$1', [deviceId])
await t.none('DELETE FROM machine_pings WHERE device_id=$1', [deviceId]) const q2 = t.none('DELETE FROM machine_pings WHERE device_id=$1', [deviceId])
await t.none('DELETE FROM machine_network_heartbeat WHERE device_id=$1', [deviceId]) const q3 = t.none('DELETE FROM machine_network_heartbeat WHERE device_id=$1', [deviceId])
await t.none('DELETE FROM machine_network_performance WHERE device_id=$1', [deviceId]) const q4 = t.none('DELETE FROM machine_network_performance WHERE device_id=$1', [deviceId])
return Promise.all([q1, q2, q3, q4])
}) })
} }