Add support for editing individual lock code slots
Some checks failed
/ build-container (push) Has been cancelled

This commit is contained in:
Finn 2024-11-22 22:25:39 -08:00
parent 6ec7434ab6
commit cafbd63f98
7 changed files with 44 additions and 8 deletions

View file

@ -130,7 +130,7 @@ func (q *Queries) GetLockCodesByCode(ctx context.Context, code string) ([]LockCo
}
const upsertCodeSlot = `-- name: UpsertCodeSlot :exec
INSERT INTO lock_code_slots (lock, slot, code, enabled, name) VALUES (?, ?, ?, ?, "") ON CONFLICT (lock, slot) DO UPDATE SET code=excluded.code, enabled=excluded.enabled
INSERT INTO lock_code_slots (lock, slot, code, enabled, name) VALUES (?, ?, ?, ?, ?) ON CONFLICT (lock, slot) DO UPDATE SET code=excluded.code, enabled=excluded.enabled, name=excluded.name
`
type UpsertCodeSlotParams struct {
@ -138,6 +138,7 @@ type UpsertCodeSlotParams struct {
Slot int64
Code string
Enabled bool
Name string
}
func (q *Queries) UpsertCodeSlot(ctx context.Context, arg UpsertCodeSlotParams) error {
@ -146,6 +147,7 @@ func (q *Queries) UpsertCodeSlot(ctx context.Context, arg UpsertCodeSlotParams)
arg.Slot,
arg.Code,
arg.Enabled,
arg.Name,
)
return err
}

View file

@ -1,5 +1,5 @@
-- name: UpsertCodeSlot :exec
INSERT INTO lock_code_slots (lock, slot, code, enabled, name) VALUES (?, ?, ?, ?, "") ON CONFLICT (lock, slot) DO UPDATE SET code=excluded.code, enabled=excluded.enabled;
INSERT INTO lock_code_slots (lock, slot, code, enabled, name) VALUES (?, ?, ?, ?, ?) ON CONFLICT (lock, slot) DO UPDATE SET code=excluded.code, enabled=excluded.enabled, name=excluded.name;
-- name: GetLockCodeBySlot :one
SELECT * FROM lock_code_slots WHERE lock = ? AND slot = ?;