feat: query GetReviewById added
This commit is contained in:
parent
b81cc86beb
commit
35a4e173f0
2 changed files with 54 additions and 5 deletions
|
|
@ -41,6 +41,55 @@ func (q *Queries) GetImageByID(ctx context.Context, illustID int64) (Image, erro
|
|||
return i, err
|
||||
}
|
||||
|
||||
const getReviewByID = `-- name: GetReviewByID :one
|
||||
|
||||
|
||||
SELECT id, data, rating, illust_id, user_id, title_id, created_at
|
||||
FROM reviews
|
||||
WHERE review_id = $1::bigint
|
||||
`
|
||||
|
||||
// -- name: ListTitles :many
|
||||
// SELECT title_id, title_names, studio_id, poster_id, signal_ids,
|
||||
//
|
||||
// title_status, rating, rating_count, release_year, release_season,
|
||||
// season, episodes_aired, episodes_all, episodes_len
|
||||
//
|
||||
// FROM titles
|
||||
// ORDER BY title_id
|
||||
// LIMIT $1 OFFSET $2;
|
||||
// -- name: UpdateTitle :one
|
||||
// UPDATE titles
|
||||
// SET
|
||||
//
|
||||
// title_names = COALESCE(sqlc.narg('title_names'), title_names),
|
||||
// studio_id = COALESCE(sqlc.narg('studio_id'), studio_id),
|
||||
// poster_id = COALESCE(sqlc.narg('poster_id'), poster_id),
|
||||
// signal_ids = COALESCE(sqlc.narg('signal_ids'), signal_ids),
|
||||
// title_status = COALESCE(sqlc.narg('title_status'), title_status),
|
||||
// release_year = COALESCE(sqlc.narg('release_year'), release_year),
|
||||
// release_season = COALESCE(sqlc.narg('release_season'), release_season),
|
||||
// episodes_aired = COALESCE(sqlc.narg('episodes_aired'), episodes_aired),
|
||||
// episodes_all = COALESCE(sqlc.narg('episodes_all'), episodes_all),
|
||||
// episodes_len = COALESCE(sqlc.narg('episodes_len'), episodes_len)
|
||||
//
|
||||
// WHERE title_id = sqlc.arg('title_id')
|
||||
// RETURNING *;
|
||||
func (q *Queries) GetReviewByID(ctx context.Context, reviewID int64) (Review, error) {
|
||||
row := q.db.QueryRow(ctx, getReviewByID, reviewID)
|
||||
var i Review
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Data,
|
||||
&i.Rating,
|
||||
&i.IllustID,
|
||||
&i.UserID,
|
||||
&i.TitleID,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getStudioByID = `-- name: GetStudioByID :one
|
||||
SELECT id, studio_name, illust_id, studio_desc
|
||||
FROM studios
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue