short/sql/query.sql

10 lines
233 B
MySQL
Raw Permalink Normal View History

2024-01-29 18:32:01 +00:00
-- name: GetURLByHash :one
SELECT * FROM urls
WHERE hash = $1;
2024-01-29 20:21:23 +00:00
-- name: InsertURL :one
INSERT INTO urls (hash, long_url)
VALUES ($1, $2)
2024-01-29 20:37:27 +00:00
ON CONFLICT (hash) DO UPDATE SET hash = EXCLUDED.hash -- force row to be returned
2024-01-29 20:21:23 +00:00
RETURNING *;