Files
libredesk/internal/template/queries.sql
T
Abhinav Raut 06db29f7f3 refactor.
2024-08-11 03:52:05 +05:30

22 lines
511 B
SQL

-- name: insert
INSERT INTO templates ("name", body, is_default)
VALUES ($1, $2, $3);
-- name: update
WITH u AS (
UPDATE templates
SET name = $2, body = $3, is_default = $4, updated_at = now()
WHERE id = $1
)
UPDATE templates
SET is_default = false
WHERE id != $1 AND $4 = true;
-- name: get-default
select id, name, body from templates where is_default is true;
-- name: get-all
select * from templates order by updated_at desc;
-- name: get-template
SELECT * from templates where id = $1;