stillbox/sql/postgres/queries/share.sql

27 lines
474 B
SQL
Raw Normal View History

-- name: GetShare :one
SELECT
id,
entity_type,
entity_id,
2025-01-19 21:51:39 -05:00
entity_date,
owner,
expiration
FROM shares
WHERE id = @id;
-- name: CreateShare :exec
INSERT INTO shares (
id,
entity_type,
entity_id,
2025-01-19 21:51:39 -05:00
entity_date,
owner,
expiration
2025-01-19 21:51:39 -05:00
) VALUES (@id, @entity_type, @entity_id, sqlc.narg('entity_date'), @owner, sqlc.narg('expiration'));
-- name: DeleteShare :exec
DELETE FROM shares WHERE id = @id;
-- name: PruneShares :exec
DELETE FROM shares WHERE expiration < NOW();