cmc-sales/go-app/sql/queries/attachments.sql
Karl Cordes 4f54a93c62 Add Go app
Add start-development.sh
2025-07-02 22:04:36 +10:00

41 lines
894 B
SQL

-- name: GetAttachment :one
SELECT * FROM attachments
WHERE id = ? LIMIT 1;
-- name: ListAttachments :many
SELECT * FROM attachments
WHERE archived = 0
ORDER BY created DESC
LIMIT ? OFFSET ?;
-- name: ListArchivedAttachments :many
SELECT * FROM attachments
WHERE archived = 1
ORDER BY created DESC
LIMIT ? OFFSET ?;
-- name: CreateAttachment :execresult
INSERT INTO attachments (
principle_id, created, modified, name, filename,
file, type, size, description, archived
) VALUES (
?, NOW(), NOW(), ?, ?, ?, ?, ?, ?, 0
);
-- name: UpdateAttachment :exec
UPDATE attachments
SET modified = NOW(),
name = ?,
description = ?
WHERE id = ?;
-- name: DeleteAttachment :exec
UPDATE attachments
SET archived = 1,
modified = NOW()
WHERE id = ?;
-- name: ListAttachmentsByPrinciple :many
SELECT * FROM attachments
WHERE principle_id = ? AND archived = 0
ORDER BY created DESC;