repo

package
v0.0.0-...-9139306 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasePO

type BasePO struct {
	Id        string                 `gorm:"type:varchar(26);primaryKey;comment:分布式全局唯一 ULID"`
	CreatedAt time.Time              `gorm:"type:datetime not null;comment:创建时间"`
	UpdatedAt time.Time              `gorm:"type:datetime not null;comment:更新时间"`
	DeletedAt gorm.DeletedAt         `gorm:"type:datetime;index;comment:删除时间"`
	Version   optimisticlock.Version `gorm:"not null;default:0;comment:版本号(乐观锁专用)"`
}

type BaseRepo

type BaseRepo[E, T any] struct {
	DB *gorm.DB
}

func (*BaseRepo[E, T]) Create

func (r *BaseRepo[E, T]) Create(ctx context.Context, value any) error

func (*BaseRepo[E, T]) Delete

func (r *BaseRepo[E, T]) Delete(ctx context.Context, ids []string, query any, conds ...any) error

func (*BaseRepo[E, T]) Find

func (r *BaseRepo[E, T]) Find(ctx context.Context, query any, conds ...any) ([]E, error)

func (*BaseRepo[E, T]) FindByPage

func (r *BaseRepo[E, T]) FindByPage(ctx context.Context, offset int, limit int, orderBy map[string]string, query any, conds ...any) ([]E, int, error)

func (*BaseRepo[E, T]) FindOne

func (r *BaseRepo[E, T]) FindOne(ctx context.Context, query any, conds ...any) (E, error)

func (*BaseRepo[E, T]) Update

func (r *BaseRepo[E, T]) Update(ctx context.Context, column string, value any, conds ...any) (E, error)

func (*BaseRepo[E, T]) Updates

func (r *BaseRepo[E, T]) Updates(ctx context.Context, values map[string]any, query any, conds ...any) (E, error)

type Repo

type Repo[E, T any] interface {
	Create(ctx context.Context, value any) error
	FindOne(ctx context.Context, query any, conds ...any) (E, error)
	Find(ctx context.Context, query any, conds ...any) ([]E, error)
	FindByPage(ctx context.Context, offset int, limit int, orderBy map[string]string, query any, conds ...any) ([]E, int, error)
	Update(ctx context.Context, column string, value any, conds ...any) (E, error)
	Updates(ctx context.Context, values map[string]any, query any, conds ...any) (E, error)
	Delete(ctx context.Context, ids []string, query any, conds ...any) error
}

Jump to

Keyboard shortcuts

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