repository

package
v0.0.0-...-90dbc55 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Car

type Car struct {
	ID           int
	Model        string
	RegisteredAt time.Time
}

type CreateCar

type CreateCar struct {
	Model        string
	RegisteredAt time.Time
}

type CreateUser

type CreateUser struct {
	Age  int
	Name string
}

type DbConfig

type DbConfig struct {
	Host     string
	Port     string
	User     string
	Password string
	Db       string
}

func ConfigFromEnv

func ConfigFromEnv() *DbConfig

func (*DbConfig) DSN

func (c *DbConfig) DSN() string

type Repository

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

func Connect

func Connect(c *DbConfig) (*Repository, error)

func New

func New(client *ent.Client) *Repository

func (*Repository) Close

func (r *Repository) Close() error

func (*Repository) CreateCar

func (r *Repository) CreateCar(ctx context.Context, car *CreateCar) (*Car, error)

func (*Repository) CreateUser

func (r *Repository) CreateUser(ctx context.Context, u *CreateUser) (*User, error)

func (*Repository) DeleteCar

func (r *Repository) DeleteCar(ctx context.Context, id int) error

func (*Repository) DeleteUser

func (r *Repository) DeleteUser(ctx context.Context, id int) error

func (*Repository) GetCar

func (r *Repository) GetCar(ctx context.Context, id int) (*Car, error)

func (*Repository) GetCars

func (r *Repository) GetCars(ctx context.Context) ([]*Car, error)

func (*Repository) GetUser

func (r *Repository) GetUser(ctx context.Context, id int) (*User, error)

func (*Repository) GetUserAndCars

func (r *Repository) GetUserAndCars(ctx context.Context, userID int) (*UserAndCars, error)

func (*Repository) GetUserCars

func (r *Repository) GetUserCars(ctx context.Context, userID int) ([]*Car, error)

func (*Repository) GetUsers

func (r *Repository) GetUsers(ctx context.Context) ([]*User, error)

func (*Repository) Migrate

func (r *Repository) Migrate(c context.Context) error

func (*Repository) UnlinkUserCars

func (r *Repository) UnlinkUserCars(ctx context.Context, userID int, cars []*Car) ([]*Car, error)

func (*Repository) UpdateCar

func (r *Repository) UpdateCar(ctx context.Context, id int, car *CreateCar) (*Car, error)

func (*Repository) UpdateUser

func (r *Repository) UpdateUser(ctx context.Context, id int, u *UpdateUser) (*User, error)

func (*Repository) UpdateUserCars

func (r *Repository) UpdateUserCars(ctx context.Context, userID int, cars []*Car) ([]*Car, error)

type UpdateUser

type UpdateUser = CreateUser

type User

type User struct {
	ID   int
	Age  int
	Name string
}

type UserAndCars

type UserAndCars struct {
	User
	Cars []*Car
}

Jump to

Keyboard shortcuts

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