mirror of
https://github.com/abhinavxd/libredesk.git
synced 2026-09-10 22:25:39 +00:00
d2e5d85e3a
All POST/PUT handlers now return actual database objects instead of `true`
73 lines
1.0 KiB
SQL
73 lines
1.0 KiB
SQL
-- name: get
|
|
SELECT
|
|
id,
|
|
name,
|
|
message_content,
|
|
created_at,
|
|
updated_at,
|
|
visibility,
|
|
user_id,
|
|
team_id,
|
|
actions,
|
|
visible_when,
|
|
usage_count
|
|
FROM
|
|
macros
|
|
WHERE
|
|
id = $1;
|
|
|
|
-- name: get-all
|
|
SELECT
|
|
id,
|
|
name,
|
|
message_content,
|
|
created_at,
|
|
updated_at,
|
|
visibility,
|
|
user_id,
|
|
team_id,
|
|
actions,
|
|
visible_when,
|
|
usage_count
|
|
FROM
|
|
macros
|
|
ORDER BY
|
|
updated_at DESC;
|
|
|
|
-- name: create
|
|
INSERT INTO
|
|
macros (name, message_content, user_id, team_id, visibility, visible_when, actions)
|
|
VALUES
|
|
($1, $2, $3, $4, $5, $6, $7)
|
|
RETURNING *;
|
|
|
|
-- name: update
|
|
UPDATE
|
|
macros
|
|
SET
|
|
name = $2,
|
|
message_content = $3,
|
|
user_id = $4,
|
|
team_id = $5,
|
|
visibility = $6,
|
|
visible_when = $7,
|
|
actions = $8,
|
|
updated_at = NOW()
|
|
WHERE
|
|
id = $1
|
|
RETURNING *;
|
|
|
|
-- name: delete
|
|
DELETE FROM
|
|
macros
|
|
WHERE
|
|
id = $1;
|
|
|
|
-- name: increment-usage-count
|
|
UPDATE
|
|
macros
|
|
SET
|
|
usage_count = usage_count + 1,
|
|
updated_at = NOW()
|
|
WHERE
|
|
id = $1; |