hugo-cms/sql/queries/posts.sql

34 lines
685 B
MySQL
Raw Normal View History

2025-01-27 03:23:54 +00:00
-- name: ListPosts :many
SELECT * FROM post WHERE site_id = $1 ORDER BY post_date DESC LIMIT 25;
-- name: GetPostWithID :one
SELECT * FROM post WHERE id = $1 LIMIT 1;
2025-01-27 04:45:53 +00:00
-- name: ListPublishablePosts :many
SELECT *
FROM post
WHERE id > $1 AND site_id = $2 AND state = 'published' AND post_date <= $3
ORDER BY id LIMIT 100;
2025-01-27 03:23:54 +00:00
-- name: InsertPost :one
INSERT INTO post (
site_id,
title,
body,
state,
props,
post_date,
created_at
) VALUES ($1, $2, $3, $4, $5, $6, $7)
RETURNING id;
-- name: UpdatePost :exec
UPDATE post SET
site_id = $2,
title = $3,
body = $4,
state = $5,
props = $6,
post_date = $7
-- updated_at = $7
WHERE id = $1;