feat: receive numberOfCassettes from machine
feat: save numberOfCassettes on devices table feat: make CashCassettes dynamic with the number of cassettes
This commit is contained in:
parent
0a3b78f75e
commit
6d6c8adabd
6 changed files with 41 additions and 83 deletions
|
|
@ -20,16 +20,16 @@ function unpair (deviceId) {
|
|||
return Promise.all([db.none(sql, [deviceId]), db.none(deleteMachinePings, [deviceId])])
|
||||
}
|
||||
|
||||
function pair (token, deviceId, machineModel) {
|
||||
function pair (token, deviceId, machineModel, numOfCassettes) {
|
||||
return pullToken(token)
|
||||
.then(r => {
|
||||
if (r.expired) return false
|
||||
|
||||
const insertSql = `insert into devices (device_id, name) values ($1, $2)
|
||||
const insertSql = `insert into devices (device_id, name, number_of_cassettes) values ($1, $2, $3)
|
||||
on conflict (device_id)
|
||||
do update set paired=TRUE, display=TRUE`
|
||||
|
||||
return db.none(insertSql, [deviceId, r.name])
|
||||
return db.none(insertSql, [deviceId, r.name, numOfCassettes])
|
||||
.then(() => true)
|
||||
})
|
||||
.catch(err => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue