bunflix

package
v0.0.0-...-dd8dd0a Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRepository

func NewRepository(driverName, dataSourceName string) benchflix.Repository

Types

type Country

type Country struct {
	bun.BaseModel `bun:"table:countries"`

	ID   int64  `bun:",pk,autoincrement"`
	Name string `bun:",unique,notnull"`
}

type Genre

type Genre struct {
	bun.BaseModel `bun:"table:genres"`

	ID   int64  `bun:",pk,autoincrement"`
	Name string `bun:",unique,notnull"`
}

type Movie

type Movie struct {
	bun.BaseModel `bun:"table:movies"`

	ID      int64     `bun:",pk,autoincrement"`
	Title   string    `bun:",notnull"`
	AddedAt time.Time `bun:",notnull"`
	Rating  float64   `bun:",notnull"`

	Directors []*Person  `bun:"m2m:movie_directors"`
	Actors    []*Person  `bun:"m2m:movie_actors"`
	Countries []*Country `bun:"m2m:movie_countries"`
	Genres    []*Genre   `bun:"m2m:movie_genres"`
}

type MovieActor

type MovieActor struct {
	bun.BaseModel `bun:"table:movie_actors"`

	MovieID  int64 `bun:",pk"`
	PersonID int64 `bun:",pk"`

	Movie  *Movie  `bun:"rel:belongs-to,join:movie_id=id"`
	Person *Person `bun:"rel:belongs-to,join:person_id=id"`
}

type MovieCountry

type MovieCountry struct {
	bun.BaseModel `bun:"table:movie_countries"`

	MovieID   int64 `bun:",pk"`
	CountryID int64 `bun:",pk"`

	Movie   *Movie   `bun:"rel:belongs-to,join:movie_id=id"`
	Country *Country `bun:"rel:belongs-to,join:country_id=id"`
}

type MovieDirector

type MovieDirector struct {
	bun.BaseModel `bun:"table:movie_directors"`

	MovieID  int64 `bun:",pk"`
	PersonID int64 `bun:",pk"`

	Movie  *Movie  `bun:"rel:belongs-to,join:movie_id=id"`
	Person *Person `bun:"rel:belongs-to,join:person_id=id"`
}

type MovieGenre

type MovieGenre struct {
	bun.BaseModel `bun:"table:movie_genres"`

	MovieID int64 `bun:",pk"`
	GenreID int64 `bun:",pk"`

	Movie *Movie `bun:"rel:belongs-to,join:movie_id=id"`
	Genre *Genre `bun:"rel:belongs-to,join:genre_id=id"`
}

type Person

type Person struct {
	bun.BaseModel `bun:"table:people"`

	ID   int64  `bun:",pk,autoincrement"`
	Name string `bun:",unique,notnull"`
}

type Repository

type Repository struct {
	DB *bun.DB
}

func (Repository) Create

func (r Repository) Create(ctx context.Context, movie benchflix.Movie) error

func (Repository) Delete

func (r Repository) Delete(ctx context.Context, id int64) error

func (Repository) Query

func (r Repository) Query(ctx context.Context, query benchflix.Query) ([]benchflix.Movie, error)

func (Repository) Read

func (r Repository) Read(ctx context.Context, id int64) (benchflix.Movie, error)

Jump to

Keyboard shortcuts

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