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.

36 lines
1.4 KiB

  1. -- name: SelectStory :one
  2. SELECT * FROM story WHERE id = $1 LIMIT 1;
  3. -- name: SelectStories :many
  4. SELECT * FROM story
  5. WHERE (@filter_id::bool = false OR id = ANY(@ids::text[]))
  6. AND (@filter_author::bool = false OR name = @author::text)
  7. AND (@filter_earlist_fictional_date::bool = false OR fictional_date >= @earliest_fictional_date::timestamp)
  8. AND (@filter_lastest_fictional_date::bool = false OR fictional_date <= @latest_fictional_date::timestamp)
  9. AND (@filter_category::bool = false OR category = @category::text)
  10. AND (@filter_open::bool = false OR open = @open::bool)
  11. AND (@filter_unlisted::bool = false OR unlisted = @unlisted::bool)
  12. ORDER BY updated_date
  13. LIMIT NULLIF(@limit_size::INT, 0);
  14. -- name: InsertStory :exec
  15. INSERT INTO story (id, author, name, category, open, listed, sort_by_fictional_date, created_date, fictional_date, updated_date)
  16. VALUES (
  17. @id::text, @author::text, @name::text, @category::text,
  18. @open::boolean, @listed::boolean, @sort_by_fictional_date::boolean,
  19. @created_date::timestamp, @fictional_date::timestamp, @updated_date::timestamp
  20. );
  21. -- name: UpdateStory :exec
  22. UPDATE story
  23. SET name = @name,
  24. category = @category,
  25. author = @author,
  26. open = @open,
  27. listed = @listed,
  28. fictional_date = @fictional_date,
  29. updated_date = @updated_date,
  30. sort_by_fictional_date = @sort_by_fictional_date
  31. WHERE id = @id;
  32. -- name: DeleteStory :exec
  33. DELETE FROM story WHERE id=$1;