database

package
v0.0.0-...-91ccb22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 27, 2026 License: CC0-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDuplicateEntryError

func IsDuplicateEntryError(err error) bool

func IsForeignKeyError

func IsForeignKeyError(err error) bool

Types

type AddToWatchlistParams

type AddToWatchlistParams struct {
	UserID  string `json:"user_id"`
	MovieID int32  `json:"movie_id"`
}

type CreateMovieParams

type CreateMovieParams struct {
	ID          int32       `json:"id"`
	Title       string      `json:"title"`
	Description pgtype.Text `json:"description"`
	ReleaseDate pgtype.Date `json:"release_date"`
	Genre       pgtype.Text `json:"genre"`
}

type CreateReviewParams

type CreateReviewParams struct {
	UserID  string      `json:"user_id"`
	MovieID int32       `json:"movie_id"`
	Rating  pgtype.Int2 `json:"rating"`
	Comment pgtype.Text `json:"comment"`
}

type CreateUserParams

type CreateUserParams struct {
	ID           string `json:"id"`
	Username     string `json:"username"`
	Email        string `json:"email"`
	PasswordHash string `json:"password_hash"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type GetUserByIdRow

type GetUserByIdRow struct {
	ID        string    `json:"id"`
	Username  string    `json:"username"`
	CreatedAt time.Time `json:"created_at"`
}

type GetUserByUsernameRow

type GetUserByUsernameRow struct {
	ID        string    `json:"id"`
	Username  string    `json:"username"`
	CreatedAt time.Time `json:"created_at"`
}

type IsMovieInWatchlistParams

type IsMovieInWatchlistParams struct {
	UserID  string `json:"user_id"`
	MovieID int32  `json:"movie_id"`
}

type ListMoviesParams

type ListMoviesParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListUsersRow

type ListUsersRow struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Username  string    `json:"username"`
}

type ListWatchlistByUserRow

type ListWatchlistByUserRow struct {
	UserID      string          `json:"user_id"`
	MovieID     int32           `json:"movie_id"`
	Status      WatchlistStatus `json:"status"`
	AddedAt     time.Time       `json:"added_at"`
	Title       string          `json:"title"`
	Description pgtype.Text     `json:"description"`
	ReleaseDate pgtype.Date     `json:"release_date"`
	Genre       pgtype.Text     `json:"genre"`
}

type Movie

type Movie struct {
	ID          int32       `json:"id"`
	Title       string      `json:"title"`
	Description pgtype.Text `json:"description"`
	ReleaseDate pgtype.Date `json:"release_date"`
	Genre       pgtype.Text `json:"genre"`
	CreatedAt   time.Time   `json:"created_at"`
}

type NullWatchlistStatus

type NullWatchlistStatus struct {
	WatchlistStatus WatchlistStatus `json:"watchlist_status"`
	Valid           bool            `json:"valid"` // Valid is true if WatchlistStatus is not NULL
}

func (*NullWatchlistStatus) Scan

func (ns *NullWatchlistStatus) Scan(value interface{}) error

Scan implements the Scanner interface.

func (NullWatchlistStatus) Value

func (ns NullWatchlistStatus) Value() (driver.Value, error)

Value implements the driver Valuer interface.

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) AddToWatchlist

func (q *Queries) AddToWatchlist(ctx context.Context, arg AddToWatchlistParams) (Watchlist, error)

func (*Queries) CreateMovie

func (q *Queries) CreateMovie(ctx context.Context, arg CreateMovieParams) (Movie, error)

func (*Queries) CreateReview

func (q *Queries) CreateReview(ctx context.Context, arg CreateReviewParams) (Review, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) DeleteMovie

func (q *Queries) DeleteMovie(ctx context.Context, id int32) error

func (*Queries) DeleteReview

func (q *Queries) DeleteReview(ctx context.Context, id int32) error

func (*Queries) DeleteUser

func (q *Queries) DeleteUser(ctx context.Context, id string) error

func (*Queries) GetAverageRatingForMovie

func (q *Queries) GetAverageRatingForMovie(ctx context.Context, movieID int32) (pgtype.Numeric, error)

func (*Queries) GetMovieById

func (q *Queries) GetMovieById(ctx context.Context, id int32) (Movie, error)

func (*Queries) GetReviewById

func (q *Queries) GetReviewById(ctx context.Context, id int32) (Review, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*Queries) GetUserById

func (q *Queries) GetUserById(ctx context.Context, id string) (GetUserByIdRow, error)

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (GetUserByUsernameRow, error)

func (*Queries) IsMovieInWatchlist

func (q *Queries) IsMovieInWatchlist(ctx context.Context, arg IsMovieInWatchlistParams) (bool, error)

func (*Queries) ListMovies

func (q *Queries) ListMovies(ctx context.Context, arg ListMoviesParams) ([]Movie, error)

func (*Queries) ListMoviesByGenre

func (q *Queries) ListMoviesByGenre(ctx context.Context, genre pgtype.Text) ([]Movie, error)

func (*Queries) ListReviewsByMovie

func (q *Queries) ListReviewsByMovie(ctx context.Context, movieID int32) ([]Review, error)

func (*Queries) ListReviewsByUser

func (q *Queries) ListReviewsByUser(ctx context.Context, userID string) ([]Review, error)

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context) ([]ListUsersRow, error)

func (*Queries) ListWatchlistByUser

func (q *Queries) ListWatchlistByUser(ctx context.Context, userID string) ([]ListWatchlistByUserRow, error)

func (*Queries) RemoveFromWatchlist

func (q *Queries) RemoveFromWatchlist(ctx context.Context, arg RemoveFromWatchlistParams) error

func (*Queries) UpdateMovie

func (q *Queries) UpdateMovie(ctx context.Context, arg UpdateMovieParams) error

func (*Queries) UpdateReview

func (q *Queries) UpdateReview(ctx context.Context, arg UpdateReviewParams) error

func (*Queries) UpdateUserPassword

func (q *Queries) UpdateUserPassword(ctx context.Context, arg UpdateUserPasswordParams) error

func (*Queries) UpdateWatchlistItem

func (q *Queries) UpdateWatchlistItem(ctx context.Context, arg UpdateWatchlistItemParams) (Watchlist, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type RemoveFromWatchlistParams

type RemoveFromWatchlistParams struct {
	UserID  string `json:"user_id"`
	MovieID int32  `json:"movie_id"`
}

type Review

type Review struct {
	ID        int32       `json:"id"`
	UserID    string      `json:"user_id"`
	MovieID   int32       `json:"movie_id"`
	Rating    pgtype.Int2 `json:"rating"`
	Comment   pgtype.Text `json:"comment"`
	CreatedAt time.Time   `json:"created_at"`
}

type UpdateMovieParams

type UpdateMovieParams struct {
	Title       string      `json:"title"`
	Description pgtype.Text `json:"description"`
	ReleaseDate pgtype.Date `json:"release_date"`
	Genre       pgtype.Text `json:"genre"`
	ID          int32       `json:"id"`
}

type UpdateReviewParams

type UpdateReviewParams struct {
	Rating  pgtype.Int2 `json:"rating"`
	Comment pgtype.Text `json:"comment"`
	ID      int32       `json:"id"`
}

type UpdateUserPasswordParams

type UpdateUserPasswordParams struct {
	PasswordHash string `json:"password_hash"`
	ID           string `json:"id"`
}

type UpdateWatchlistItemParams

type UpdateWatchlistItemParams struct {
	Status  WatchlistStatus `json:"status"`
	UserID  string          `json:"user_id"`
	MovieID int32           `json:"movie_id"`
}

type User

type User struct {
	ID           string    `json:"id"`
	Username     string    `json:"username"`
	Email        string    `json:"email"`
	PasswordHash string    `json:"password_hash"`
	CreatedAt    time.Time `json:"created_at"`
}

type Watchlist

type Watchlist struct {
	UserID  string          `json:"user_id"`
	MovieID int32           `json:"movie_id"`
	Status  WatchlistStatus `json:"status"`
	AddedAt time.Time       `json:"added_at"`
}

type WatchlistStatus

type WatchlistStatus string
const (
	WatchlistStatusFinished WatchlistStatus = "finished"
	WatchlistStatusWatching WatchlistStatus = "watching"
	WatchlistStatusPlanned  WatchlistStatus = "planned"
	WatchlistStatusHold     WatchlistStatus = "hold"
	WatchlistStatusDropped  WatchlistStatus = "dropped"
)

func (*WatchlistStatus) Scan

func (e *WatchlistStatus) Scan(src interface{}) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL