repository

package
v0.0.0-...-5043ddc Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDB

func NewDB(conf *viper.Viper, l *log.Logger) *gorm.DB

func NewRedis

func NewRedis(conf *viper.Viper) *redis.Client

Types

type Repository

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

func NewRepository

func NewRepository(
	logger *log.Logger,
	db *gorm.DB,

) *Repository

func (*Repository) DB

func (r *Repository) DB(ctx context.Context) *gorm.DB

DB return tx If you need to create a Transaction, you must call DB(ctx) and Transaction(ctx,fn)

func (*Repository) Transaction

func (r *Repository) Transaction(ctx context.Context, fn func(ctx context.Context) error) error

type Transaction

type Transaction interface {
	Transaction(ctx context.Context, fn func(ctx context.Context) error) error
}

func NewTransaction

func NewTransaction(r *Repository) Transaction

type UserRepository

type UserRepository interface {
	Create(ctx context.Context, user *model.User) error
	Update(ctx context.Context, user *model.User) error
	GetByID(ctx context.Context, id string) (*model.User, error)
	GetByEmail(ctx context.Context, email string) (*model.User, error)
}

func NewUserRepository

func NewUserRepository(
	r *Repository,
) UserRepository

Jump to

Keyboard shortcuts

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