gator/sql/postgres/queries/feeds.sql
Dan Anglin cfa6a4abad
refactor: move postgres SQL files
Move the postgres SQL schema and query files to sql/postgres.
2024-10-01 06:51:10 +01:00

37 lines
497 B
SQL

-- name: CreateFeed :one
INSERT INTO feeds(
id,
created_at,
updated_at,
name,
url,
user_id
)
VALUES (
$1,
$2,
$3,
$4,
$5,
$6
)
RETURNING *;
-- name: GetAllFeeds :many
SELECT *
FROM feeds;
-- name: GetFeedByUrl :one
SELECT *
FROM feeds
WHERE url = $1;
-- name: MarkFeedFetched :exec
UPDATE feeds
SET last_fetched_at = $2, updated_at = $3
WHERE id = $1;
-- name: GetNextFeedToFetch :one
SELECT *
FROM feeds
ORDER BY last_fetched_at ASC NULLS FIRST LIMIT 1;