-- name: SelectStory :one
SELECT * FROM story WHERE id = $1 LIMIT 1;

-- name: SelectStories :many
SELECT * FROM story
WHERE (sqlc.arg(filter_id)::bool = false OR id = ANY(sqlc.arg(ids)::text[]))
  AND (sqlc.arg(filter_author)::bool = false OR name = sqlc.arg(author)::text)
  AND (sqlc.arg(filter_earlist_fictional_date)::bool = false OR fictional_date >= sqlc.arg(earliest_fictional_date)::timestamp)
  AND (sqlc.arg(filter_lastest_fictional_date)::bool = false OR fictional_date <= sqlc.arg(latest_fictional_date)::timestamp)
  AND (sqlc.arg(filter_category)::bool = false OR category = sqlc.arg(category)::text)
  AND (sqlc.arg(filter_open)::bool = false OR open = sqlc.arg(open)::bool)
  AND (sqlc.arg(filter_unlisted)::bool = false OR unlisted = sqlc.arg(unlisted)::bool)
LIMIT sqlc.arg(limit_size)::int;
