2024-04-09 04:25:36 +00:00
|
|
|
-- name: UpsertCodeSlot :exec
|
2024-11-23 06:54:56 +00:00
|
|
|
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: UpdateCodeSlot :exec
|
|
|
|
UPDATE lock_code_slots SET code = ?, enabled = ?, name = ? WHERE lock = ? AND slot = ?;
|
2024-04-09 04:25:36 +00:00
|
|
|
|
|
|
|
-- name: GetLockCodeBySlot :one
|
|
|
|
SELECT * FROM lock_code_slots WHERE lock = ? AND slot = ?;
|
|
|
|
|
2024-11-23 03:50:18 +00:00
|
|
|
-- name: GetAllLockCodesByLock :many
|
2024-04-09 04:25:36 +00:00
|
|
|
SELECT * FROM lock_code_slots WHERE lock = ?;
|
2024-11-23 03:50:18 +00:00
|
|
|
|
|
|
|
-- name: GetLockCodesByCode :many
|
|
|
|
SELECT * FROM lock_code_slots WHERE code = ?;
|
|
|
|
|
|
|
|
-- name: GetEmptySlot :one
|
|
|
|
SELECT * FROM lock_code_slots WHERE lock = ? AND enabled = 0 LIMIT 1;
|
|
|
|
|
|
|
|
-- name: CountUsedSlots :one
|
|
|
|
SELECT COUNT(*) FROM lock_code_slots WHERE lock = ? AND enabled = 1;
|