GraphQL API and utilities for the rpdata project
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
1.4 KiB

-- name: SelectStory :one
SELECT * FROM story WHERE id = $1 LIMIT 1;
-- name: SelectStories :many
SELECT * FROM story
WHERE (@filter_id::bool = false OR id = ANY(@ids::text[]))
AND (@filter_author::bool = false OR name = @author::text)
AND (@filter_earlist_fictional_date::bool = false OR fictional_date >= @earliest_fictional_date::timestamp)
AND (@filter_lastest_fictional_date::bool = false OR fictional_date <= @latest_fictional_date::timestamp)
AND (@filter_category::bool = false OR category = @category::text)
AND (@filter_open::bool = false OR open = @open::bool)
AND (@filter_unlisted::bool = false OR unlisted = @unlisted::bool)
ORDER BY updated_date
LIMIT NULLIF(@limit_size::INT, 0);
-- name: InsertStory :exec
INSERT INTO story (id, author, name, category, open, listed, sort_by_fictional_date, created_date, fictional_date, updated_date)
VALUES (
@id::text, @author::text, @name::text, @category::text,
@open::boolean, @listed::boolean, @sort_by_fictional_date::boolean,
@created_date::timestamp, @fictional_date::timestamp, @updated_date::timestamp
);
-- name: UpdateStory :exec
UPDATE story
SET name = @name,
category = @category,
author = @author,
open = @open,
listed = @listed,
fictional_date = @fictional_date,
updated_date = @updated_date,
sort_by_fictional_date = @sort_by_fictional_date
WHERE id = @id;
-- name: DeleteStory :exec
DELETE FROM story WHERE id=$1;