// Code generated by sqlc. DO NOT EDIT. // source: chapters.sql package psqlcore import ( "context" "time" ) const deleteChapter = `-- name: DeleteChapter :exec DELETE FROM story_chapter WHERE id=$1 ` func (q *Queries) DeleteChapter(ctx context.Context, id string) error { _, err := q.db.ExecContext(ctx, deleteChapter, id) return err } const deleteChaptersByStoryID = `-- name: DeleteChaptersByStoryID :exec DELETE FROM story_chapter WHERE story_id=$1 ` func (q *Queries) DeleteChaptersByStoryID(ctx context.Context, storyID string) error { _, err := q.db.ExecContext(ctx, deleteChaptersByStoryID, storyID) return err } const insertChapter = `-- name: InsertChapter :exec INSERT INTO story_chapter (id, story_id, title, author, source, created_date, fictional_date, edited_date, comment_mode, comments_locked) VALUES ( $1::TEXT, $2::TEXT, $3::TEXT, $4::TEXT, $5::TEXT, $6::TIMESTAMP, $7::TIMESTAMP, $8::TIMESTAMP, $9::TEXT, $10::BOOLEAN ) ` type InsertChapterParams struct { ID string `json:"id"` StoryID string `json:"story_id"` Title string `json:"title"` Author string `json:"author"` Source string `json:"source"` CreatedDate time.Time `json:"created_date"` FictionalDate time.Time `json:"fictional_date"` EditedDate time.Time `json:"edited_date"` CommentMode string `json:"comment_mode"` CommentsLocked bool `json:"comments_locked"` } func (q *Queries) InsertChapter(ctx context.Context, arg InsertChapterParams) error { _, err := q.db.ExecContext(ctx, insertChapter, arg.ID, arg.StoryID, arg.Title, arg.Author, arg.Source, arg.CreatedDate, arg.FictionalDate, arg.EditedDate, arg.CommentMode, arg.CommentsLocked, ) return err } const selectChapter = `-- name: SelectChapter :one SELECT id, story_id, title, author, source, created_date, fictional_date, edited_date, comment_mode, comments_locked FROM story_chapter WHERE id=$1::TEXT LIMIT 1 ` func (q *Queries) SelectChapter(ctx context.Context, dollar_1 string) (StoryChapter, error) { row := q.db.QueryRowContext(ctx, selectChapter, dollar_1) var i StoryChapter err := row.Scan( &i.ID, &i.StoryID, &i.Title, &i.Author, &i.Source, &i.CreatedDate, &i.FictionalDate, &i.EditedDate, &i.CommentMode, &i.CommentsLocked, ) return i, err } const selectChapters = `-- name: SelectChapters :many SELECT id, story_id, title, author, source, created_date, fictional_date, edited_date, comment_mode, comments_locked FROM story_chapter WHERE (sqlx.arg(story_id)::TEXT == '' OR story_id=$1::TEXT) ORDER BY created_date LIMIT $2::INT ` type SelectChaptersParams struct { StoryID string `json:"story_id"` LimitSize int32 `json:"limit_size"` } func (q *Queries) SelectChapters(ctx context.Context, arg SelectChaptersParams) ([]StoryChapter, error) { rows, err := q.db.QueryContext(ctx, selectChapters, arg.StoryID, arg.LimitSize) if err != nil { return nil, err } defer rows.Close() items := []StoryChapter{} for rows.Next() { var i StoryChapter if err := rows.Scan( &i.ID, &i.StoryID, &i.Title, &i.Author, &i.Source, &i.CreatedDate, &i.FictionalDate, &i.EditedDate, &i.CommentMode, &i.CommentsLocked, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil } const updateChapter = `-- name: UpdateChapter :exec UPDATE story_chapter SET title=$1, source=$2, fictional_date=$3, comment_mode=$4, comments_locked=$5 WHERE id=$6 ` type UpdateChapterParams struct { Title string `json:"title"` Source string `json:"source"` FictionalDate time.Time `json:"fictional_date"` CommentMode string `json:"comment_mode"` CommentsLocked bool `json:"comments_locked"` ID string `json:"id"` } func (q *Queries) UpdateChapter(ctx context.Context, arg UpdateChapterParams) error { _, err := q.db.ExecContext(ctx, updateChapter, arg.Title, arg.Source, arg.FictionalDate, arg.CommentMode, arg.CommentsLocked, arg.ID, ) return err } const updateChapterStoryID = `-- name: UpdateChapterStoryID :exec UPDATE story_chapter SET story_id=$1::TEXT WHERE id=$2 ` type UpdateChapterStoryIDParams struct { StoryID string `json:"story_id"` ID string `json:"id"` } func (q *Queries) UpdateChapterStoryID(ctx context.Context, arg UpdateChapterStoryIDParams) error { _, err := q.db.ExecContext(ctx, updateChapterStoryID, arg.StoryID, arg.ID) return err }