-- name: SelectComment :one SELECT * FROM story_comment WHERE id=$1; -- name: InsertComment :exec INSERT INTO story_comment (id, chapter_id, character_id, subject, author, character_name, source, created_date, fictional_date, edited_date) VALUES ( @id, @chapter_id, @character_id, @subject, @author, @character_name, @source, @created_date, @fictional_date, @edited_date ); -- name: UpdateComment :exec UPDATE story_comment SET subject = @subject, source = @source, fictional_date = @fictional_date, character_name = @character_name, character_id = @character_id WHERE id = @id; -- name: SelectComments :many SELECT * FROM story_comment WHERE (@chapter_id = '' OR chapter_id = @chapter_id) LIMIT NULLIF(@limit_size::INT, 0); -- name: DeleteComment :exec DELETE FROM story_comment WHERE id = $1; -- name: DeleteCommentsByChapterID :exec DELETE FROM story_comment WHERE chapter_id = $1; -- name: DeleteCommentsByStoryID :exec DELETE FROM story_comment WHERE chapter_id IN ( SELECT id FROM story_chapter WHERE story_id = $1 );