Versions in this module Expand all Collapse all v0 v0.2.0 Oct 15, 2025 Changes in this version + type BaseModel struct + func NewBaseModel[T any](db *gorm.DB) (*BaseModel[T], error) + func (r *BaseModel[T]) BatchInsert(ctx context.Context, tx *gorm.DB, ents []*T, batchSize ...int) error + func (r *BaseModel[T]) Count(ctx context.Context, scopes ...Scope) (int64, error) + func (r *BaseModel[T]) Create(ctx context.Context, tx *gorm.DB, ent *T) error + func (r *BaseModel[T]) Delete(ctx context.Context, tx *gorm.DB, scopes ...Scope) error + func (r *BaseModel[T]) Exists(ctx context.Context, scopes ...Scope) (bool, error) + func (r *BaseModel[T]) FindForUpdate(ctx context.Context, tx *gorm.DB, scopes ...Scope) ([]T, error) + func (r *BaseModel[T]) First(ctx context.Context, scopes ...Scope) (T, error) + func (r *BaseModel[T]) FirstForUpdate(ctx context.Context, tx *gorm.DB, scopes ...Scope) (T, error) + func (r *BaseModel[T]) List(ctx context.Context, scopes ...Scope) ([]T, error) + func (r *BaseModel[T]) Page(ctx context.Context, page, pageSize int, scopes ...Scope) (PageResult[T], error) + func (r *BaseModel[T]) Transact(ctx context.Context, fn func(ctx context.Context, tx *gorm.DB) error) error + func (r *BaseModel[T]) Update(ctx context.Context, tx *gorm.DB, ent *T) error + func (r *BaseModel[T]) UpdateColumn(ctx context.Context, tx *gorm.DB, column string, value any, scopes ...Scope) error + func (r *BaseModel[T]) UpdateColumns(ctx context.Context, tx *gorm.DB, updates any, scopes ...Scope) error v0.1.0 Sep 10, 2025 Changes in this version + var ErrDangerous = errors.New("dangerous operation is prohibited") + var ErrInvalidType = errors.New("generic type must be a struct type") + var ErrNotFound = errors.New("not found") + var ErrTxRequired = errors.New("tx is required") + type PageResult struct + HasNext bool + Items []T + Page int + PageSize int + Total int64 + type Repo struct + func NewRepo[T any](db *gorm.DB) (*Repo[T], error) + func (r *Repo[T]) BatchInsert(ctx context.Context, tx *gorm.DB, ents []*T, batchSize ...int) error + func (r *Repo[T]) Count(ctx context.Context, scopes ...Scope) (int64, error) + func (r *Repo[T]) Create(ctx context.Context, tx *gorm.DB, ent *T) error + func (r *Repo[T]) Delete(ctx context.Context, tx *gorm.DB, scopes ...Scope) error + func (r *Repo[T]) Exists(ctx context.Context, scopes ...Scope) (bool, error) + func (r *Repo[T]) FindForUpdate(ctx context.Context, tx *gorm.DB, scopes ...Scope) ([]T, error) + func (r *Repo[T]) First(ctx context.Context, scopes ...Scope) (T, error) + func (r *Repo[T]) FirstForUpdate(ctx context.Context, tx *gorm.DB, scopes ...Scope) (T, error) + func (r *Repo[T]) List(ctx context.Context, scopes ...Scope) ([]T, error) + func (r *Repo[T]) Page(ctx context.Context, page, pageSize int, scopes ...Scope) (PageResult[T], error) + func (r *Repo[T]) Transact(ctx context.Context, fn func(ctx context.Context, tx *gorm.DB) error) error + func (r *Repo[T]) Update(ctx context.Context, tx *gorm.DB, ent *T) error + type Scope func(*gorm.DB) *gorm.DB + func Limit(n int) Scope + func Offset(n int) Scope + func OnlyDeleted() Scope + func Order(order string) Scope + func Select(cols ...string) Scope + func Where(query any, args ...any) Scope + func WhereEq(m map[string]any) Scope + func WithDeleted() Scope