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.1 KiB

  1. -- name: SelectChapter :one
  2. SELECT * FROM story_chapter WHERE id=$1::TEXT LIMIT 1;
  3. -- name: SelectChapters :many
  4. SELECT * FROM story_chapter
  5. WHERE (@story_id::TEXT = '' OR story_id = @story_id::TEXT)
  6. ORDER BY created_date
  7. LIMIT NULLIF(@limit_size::INT, 0);
  8. -- name: InsertChapter :exec
  9. INSERT INTO story_chapter (id, story_id, title, author, source, created_date, fictional_date, edited_date, comment_mode, comments_locked)
  10. VALUES (
  11. @id::TEXT, @story_id::TEXT, @title::TEXT, @author::TEXT, @source::TEXT,
  12. @created_date::TIMESTAMP, @fictional_date::TIMESTAMP, @edited_date::TIMESTAMP,
  13. @comment_mode::TEXT, @comments_locked::BOOLEAN
  14. );
  15. -- name: UpdateChapterStoryID :exec
  16. UPDATE story_chapter
  17. SET story_id = @story_id::TEXT
  18. WHERE id = @id;
  19. -- name: UpdateChapter :exec
  20. UPDATE story_chapter
  21. SET title = @title,
  22. source = @source,
  23. fictional_date = @fictional_date,
  24. comment_mode = @comment_mode,
  25. comments_locked = @comments_locked
  26. WHERE id = @id;
  27. -- name: DeleteChapter :exec
  28. DELETE FROM story_chapter WHERE id=$1;
  29. -- name: DeleteChaptersByStoryID :exec
  30. DELETE FROM story_chapter WHERE story_id=$1;