dependency

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BATCH_SIZE = 1000 // default batch size
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseOption

type BaseOption struct {
	Ignore    bool     `json:"ignore"`    // ignore if exist
	Lock      bool     `json:"lock"`      // lock row
	ReadOnly  bool     `json:"readOnly"`  // read only
	Selects   []string `json:"selects"`   // select fields
	Omits     []string `json:"omits"`     // omit fields select omit
	Conds     []any    `json:"conds"`     // conds where
	Page      IPage    `json:"page"`      // page
	BatchSize int64    `json:"batchSize"` // exec by batch
}

BaseOption base repo exec

func NewBaseOption added in v0.0.7

func NewBaseOption(opts ...BaseOptionFunc) *BaseOption

NewBaseOption with func

type BaseOptionFunc added in v0.0.7

type BaseOptionFunc func(o *BaseOption)

BaseOptionFunc base option func

func WithBatchSize added in v0.0.7

func WithBatchSize(v int64) BaseOptionFunc

WithBatchSize

func WithConds added in v0.0.7

func WithConds(vs ...any) BaseOptionFunc

WithConds

func WithIgnore added in v0.0.7

func WithIgnore(v bool) BaseOptionFunc

WithIgnore

func WithLock added in v0.0.7

func WithLock(v bool) BaseOptionFunc

WithLock

func WithOmits added in v0.0.7

func WithOmits(vs ...string) BaseOptionFunc

WithOmits

func WithPage added in v0.0.7

func WithPage(v IPage) BaseOptionFunc

WithPage

func WithReadOnly added in v0.0.7

func WithReadOnly(v bool) BaseOptionFunc

WithReadOnly

func WithSelects added in v0.0.7

func WithSelects(vs ...string) BaseOptionFunc

WithSelects

type DbAction

type DbAction func(ctx context.Context) error

action

type IBizRequest

type IBizRequest interface {
	GetBizId() int64
	ToUrlQuery() url.Values
}

IBizRequest business tag reqquest

type IEntity

type IEntity interface {
	IPo
}

type IPage

type IPage interface {
	GetPageIndex() int64
	GetPageSize() int64
	GetBegin() int64
	GetSize() int64
	GetSorts() []ISortField
}

IPage page request

type IPaginator

type IPaginator interface {
	IPage
	GetTotalRecord() int64
	GetTotalPage() int64
}

type IPo

type IPo interface {
	ID() any
	TableName() string
	Database() string
}

IPo for db po struct

type IRange

type IRange interface {
	GetBeg() int64
	GetEnd() int64
}

IRange range

type IRepository

type IRepository[T IEntity] interface {
	BaseCreate(ctx context.Context, ps []*T, opts ...BaseOptionFunc) (int64, error)
	BaseSave(ctx context.Context, ps []*T, opts ...BaseOptionFunc) (int64, error)
	BaseUpdate(ctx context.Context, p *T, opts ...BaseOptionFunc) (int64, error)
	BaseGet(ctx context.Context, opts ...BaseOptionFunc) (*T, error)
	BaseDelete(ctx context.Context, p *T, opts ...BaseOptionFunc) (int64, error)
	BaseCount(ctx context.Context, opts ...BaseOptionFunc) (int64, error)
	BaseQuery(ctx context.Context, opts ...BaseOptionFunc) ([]T, error)
}

IRepository repo

type ISortField

type ISortField interface {
	GetField() string
	GetIsDesc() bool
}

ISortField sort field

type IUnitOfWork

type IUnitOfWork interface {
	Execute(ctx context.Context, fs ...DbAction) (e error)
}

IUnitOfWork trans

Jump to

Keyboard shortcuts

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