feat: add GetAnime query
This commit is contained in:
@@ -14,6 +14,7 @@ type Querier interface {
|
||||
DeleteSession(ctx context.Context, id string) error
|
||||
DeleteUserSessions(ctx context.Context, userID string) error
|
||||
DeleteWatchListEntry(ctx context.Context, arg DeleteWatchListEntryParams) error
|
||||
GetAnime(ctx context.Context, id int64) (Anime, error)
|
||||
GetSession(ctx context.Context, id string) (Session, error)
|
||||
GetUser(ctx context.Context, id string) (User, error)
|
||||
GetUserByUsername(ctx context.Context, username string) (User, error)
|
||||
|
||||
@@ -31,6 +31,9 @@ ON CONFLICT (id) DO UPDATE SET
|
||||
image_url = excluded.image_url
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetAnime :one
|
||||
SELECT * FROM anime WHERE id = ? LIMIT 1;
|
||||
|
||||
-- name: UpsertWatchListEntry :one
|
||||
INSERT INTO watch_list_entry (id, user_id, anime_id, status, updated_at)
|
||||
VALUES (?, ?, ?, ?, CURRENT_TIMESTAMP)
|
||||
|
||||
@@ -91,6 +91,22 @@ func (q *Queries) DeleteWatchListEntry(ctx context.Context, arg DeleteWatchListE
|
||||
return err
|
||||
}
|
||||
|
||||
const getAnime = `-- name: GetAnime :one
|
||||
SELECT id, title, image_url, created_at FROM anime WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
func (q *Queries) GetAnime(ctx context.Context, id int64) (Anime, error) {
|
||||
row := q.db.QueryRowContext(ctx, getAnime, id)
|
||||
var i Anime
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Title,
|
||||
&i.ImageUrl,
|
||||
&i.CreatedAt,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getSession = `-- name: GetSession :one
|
||||
SELECT id, user_id, expires_at, created_at FROM session WHERE id = ? LIMIT 1
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user