rdb

package
v0.0.0-...-4045c10 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDbInstance

func GetDbInstance() (*gorm.DB, error)

func Migrate

func Migrate(db *gorm.DB)

func MigrateWithDelete

func MigrateWithDelete(db *gorm.DB)

func NewDb

func NewDb() (*gorm.DB, error)

func NewTestDb

func NewTestDb() (*gorm.DB, error)

Types

type IdField

type IdField struct {
	Id uint `gorm:"primarykey"`
}

type Rdb

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

func (*Rdb) Transaction

func (r *Rdb) Transaction(f func() error) error

type SingletonDbInstance

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

type TimeFields

type TimeFields struct {
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

type User

type User struct {
	IdField
	Name string
	TimeFields
}

type UsersRepository

type UsersRepository struct {
	*Rdb
}

func NewUsersRepository

func NewUsersRepository(db *gorm.DB) UsersRepository

func (UsersRepository) Create

func (u UsersRepository) Create(name string) (user.User, error)

func (UsersRepository) Delete

func (u UsersRepository) Delete(id string) error

func (UsersRepository) GetAll

func (u UsersRepository) GetAll() ([]user.User, error)

func (UsersRepository) Update

func (u UsersRepository) Update(id string, name string) (user.User, error)

Jump to

Keyboard shortcuts

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