xgorm

package
v0.0.0-...-c702e84 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDBClient

func NewDBClient(configPath string) *gorm.DB

NewDBClient ...

func ToGormScopes

func ToGormScopes(scopes []Scope) []func(db *gorm.DB) *gorm.DB

ToGormScopes ...

func ToMap

func ToMap(maps []Map) map[string]interface{}

ToMap ...

Types

type BaseRepo

type BaseRepo[T any] struct {
	// contains filtered or unexported fields
}

func NewBaseRepo

func NewBaseRepo[T any](rDB *gorm.DB, rwDB *gorm.DB) *BaseRepo[T]

NewBaseRepo ...

func (*BaseRepo[T]) Create

func (b *BaseRepo[T]) Create(ctx context.Context, t *T, tx ...*gorm.DB) error

Create ...

func (*BaseRepo[T]) GetByScopes

func (b *BaseRepo[T]) GetByScopes(ctx context.Context, scopes []Scope, tx ...*gorm.DB) (*T, error)

GetByScopes ...

func (*BaseRepo[T]) GetCountByScopes

func (b *BaseRepo[T]) GetCountByScopes(ctx context.Context, scopes []Scope, tx ...*gorm.DB) (int64, error)

GetCountByScopes ...

func (*BaseRepo[T]) GetListByScopes

func (b *BaseRepo[T]) GetListByScopes(ctx context.Context, scopes []Scope, tx ...*gorm.DB) ([]*T, error)

GetListByScopes ...

func (*BaseRepo[T]) MapExprAdd

func (b *BaseRepo[T]) MapExprAdd(k string, v interface{}) Map

MapExprAdd ...

func (*BaseRepo[T]) MapExprSub

func (b *BaseRepo[T]) MapExprSub(k string, v interface{}) Map

MapExprSub ...

func (*BaseRepo[T]) MapKV

func (b *BaseRepo[T]) MapKV(k string, v interface{}) Map

func (*BaseRepo[T]) SaveByScopes

func (b *BaseRepo[T]) SaveByScopes(ctx context.Context, t *T, scopes []Scope, tx ...*gorm.DB) error

SaveByScopes ...

func (*BaseRepo[T]) ScopeBetween

func (b *BaseRepo[T]) ScopeBetween(k string, v1, v2 interface{}) Scope

ScopeBetween ...

func (*BaseRepo[T]) ScopeEqual

func (b *BaseRepo[T]) ScopeEqual(k string, v interface{}) Scope

ScopeEqual ...

func (*BaseRepo[T]) ScopeGT

func (b *BaseRepo[T]) ScopeGT(k string, v interface{}) Scope

ScopeGT ...

func (*BaseRepo[T]) ScopeGTE

func (b *BaseRepo[T]) ScopeGTE(k string, v interface{}) Scope

ScopeGTE ...

func (*BaseRepo[T]) ScopeIN

func (b *BaseRepo[T]) ScopeIN(k string, v interface{}) Scope

ScopeIN ...

func (*BaseRepo[T]) ScopeLT

func (b *BaseRepo[T]) ScopeLT(k string, v interface{}) Scope

ScopeLT ...

func (*BaseRepo[T]) ScopeLTE

func (b *BaseRepo[T]) ScopeLTE(k string, v interface{}) Scope

ScopeLTE ...

func (*BaseRepo[T]) ScopeLike

func (b *BaseRepo[T]) ScopeLike(k string, v interface{}) Scope

ScopeLike ...

func (*BaseRepo[T]) ScopeLimit

func (b *BaseRepo[T]) ScopeLimit(v interface{}) Scope

ScopeLimit ...

func (*BaseRepo[T]) ScopeNotEqual

func (b *BaseRepo[T]) ScopeNotEqual(k string, v interface{}) Scope

ScopeNotEqual ...

func (*BaseRepo[T]) ScopeOffset

func (b *BaseRepo[T]) ScopeOffset(v interface{}) Scope

ScopeOffset ...

func (*BaseRepo[T]) ScopeOrderBy

func (b *BaseRepo[T]) ScopeOrderBy(v string) Scope

ScopeOrderBy ...

func (*BaseRepo[T]) Transaction

func (b *BaseRepo[T]) Transaction(f func(tx *gorm.DB) error) error

Transaction ...

func (*BaseRepo[T]) UpdateByScopesAndMaps

func (b *BaseRepo[T]) UpdateByScopesAndMaps(ctx context.Context, scopes []Scope, maps []Map, tx ...*gorm.DB) error

UpdateByScopesAndMaps ...

type ICreator

type ICreator[T any] interface {
	Create(ctx context.Context, t *T, tx ...*gorm.DB) error
}

type IGetter

type IGetter[T any] interface {
	GetByScopes(ctx context.Context, scopes []Scope, tx ...*gorm.DB) (*T, error)
	GetCountByScopes(ctx context.Context, scopes []Scope, tx ...*gorm.DB) (int64, error)
	GetListByScopes(ctx context.Context, scopes []Scope, tx ...*gorm.DB) ([]*T, error)
}

type ITx

type ITx interface {
	Transaction(fc func(tx *gorm.DB) error) error
}

type IUpdater

type IUpdater[T any] interface {
	SaveByScopes(ctx context.Context, t *T, scopes []Scope, tx ...*gorm.DB) error
	UpdateByScopesAndMaps(ctx context.Context, scopes []Scope, maps []Map, tx ...*gorm.DB) error
}

type Map

type Map map[string]interface{}

type Scope

type Scope func(db *gorm.DB) *gorm.DB

Jump to

Keyboard shortcuts

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