27 lines
643 B
SQL
27 lines
643 B
SQL
-- name: CountCategories :one
|
|
SELECT COUNT(*) FROM project_categories;
|
|
|
|
-- name: ListCategories :many
|
|
SELECT * FROM project_categories
|
|
ORDER BY sort ASC, created_at ASC;
|
|
|
|
-- name: ListActiveCategories :many
|
|
SELECT * FROM project_categories
|
|
WHERE status = 'active'
|
|
ORDER BY sort ASC, created_at ASC;
|
|
|
|
-- name: CreateCategory :one
|
|
INSERT INTO project_categories (id, name, sort, status)
|
|
VALUES (?, ?, ?, ?)
|
|
RETURNING *;
|
|
|
|
-- name: UpdateCategory :one
|
|
UPDATE project_categories
|
|
SET name = ?, sort = ?, status = ?, updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
RETURNING *;
|
|
|
|
-- name: DeleteCategory :exec
|
|
DELETE FROM project_categories
|
|
WHERE id = ?;
|