17 lines
674 B
SQL
17 lines
674 B
SQL
-- 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, name=excluded.name;
|
|
|
|
-- name: GetLockCodeBySlot :one
|
|
SELECT * FROM lock_code_slots WHERE lock = ? AND slot = ?;
|
|
|
|
-- name: GetAllLockCodesByLock :many
|
|
SELECT * FROM lock_code_slots WHERE lock = ?;
|
|
|
|
-- 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;
|