orm

package module
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 30 Imported by: 0

README

ORM

Golang ORM designed for optimal performance with MySQL and Redis

Official documentation

Documentation

Index

Constants

View Source
const DefaultPoolCode = "default"

Variables

This section is empty.

Functions

func ConsumeAsyncBuffer added in v1.4.0

func ConsumeAsyncBuffer(ctx Context, errF func(err error)) (stop func())

func ConsumeAsyncFlushEvents added in v1.4.0

func ConsumeAsyncFlushEvents(ctx Context, block bool) error

func Copy added in v1.4.0

func Copy[E any](ctx Context, source E) E

func DeleteEntity added in v1.4.0

func DeleteEntity[E any](ctx Context, source E)

func EditEntity added in v1.4.0

func EditEntity[E any](ctx Context, source E) E

func EditEntityField added in v1.4.0

func EditEntityField(ctx Context, entity any, field string, value any) error

func GetByID added in v1.4.0

func GetByID[E any, I ID](ctx Context, id I) (entity *E, found bool)

func GetByUniqueIndex added in v1.4.0

func GetByUniqueIndex[E any](ctx Context, indexName string, attributes ...any) (entity *E, found bool)

func GetEntityField added in v1.5.0

func GetEntityField(ctx Context, entity any, field string) any

func GetEntityFieldDefinition added in v1.5.0

func GetEntityFieldDefinition[E any](ctx Context, field string) (t reflect.Type, tags map[string]string)

func GetEntityFields added in v1.5.0

func GetEntityFields(ctx Context, entity any, field ...string) map[string]any

func MustByID added in v1.4.0

func MustByID[E any, I ID](ctx Context, id I) *E

func NewEntity added in v1.4.0

func NewEntity[E any](ctx Context) *E

func NewEntityWithID added in v1.6.0

func NewEntityWithID[E any, I ID](ctx Context, id I) *E

func SearchIDs added in v1.4.0

func SearchIDs[E any](ctx Context, where Where, pager *Pager) []uint64

func SearchIDsWithCount added in v1.4.0

func SearchIDsWithCount[E any](ctx Context, where Where, pager *Pager) (results []uint64, totalRows int)

func SearchOne added in v1.4.0

func SearchOne[E any](ctx Context, where Where) (entity *E, found bool)

Types

type Alter

type Alter struct {
	SQL  string
	Safe bool
	Pool string
}

func GetAlters added in v1.4.0

func GetAlters(ctx Context) (alters []Alter)

func (Alter) Exec added in v1.3.0

func (a Alter) Exec(ctx Context)

type AsyncFlushEvents added in v1.4.0

type AsyncFlushEvents interface {
	EntitySchemas() []EntitySchema
	EventsCount() uint64
	ErrorsCount() uint64
	Events(total int) []FlushEvent
	Errors(total int, last bool) []FlushEventWithError
	TrimEvents(total int)
	TrimErrors(total int)
	RedilPool() string
	RedisList() string
}

func ReadAsyncFlushEvents added in v1.4.0

func ReadAsyncFlushEvents(ctx Context) []AsyncFlushEvents

type BaseWhere added in v1.4.0

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

func NewWhere

func NewWhere(query string, parameters ...any) *BaseWhere

func (*BaseWhere) Append added in v1.4.0

func (w *BaseWhere) Append(query string, parameters ...any)

func (*BaseWhere) GetParameters added in v1.4.0

func (w *BaseWhere) GetParameters() []any

func (*BaseWhere) SetParameter added in v1.4.0

func (w *BaseWhere) SetParameter(index int, param any) *BaseWhere

func (*BaseWhere) SetParameters added in v1.4.0

func (w *BaseWhere) SetParameters(params ...any) *BaseWhere

func (*BaseWhere) String added in v1.4.0

func (w *BaseWhere) String() string

type Bind

type Bind map[string]any

func IsDirty added in v1.4.0

func IsDirty[E any, I ID](ctx Context, id I) (oldValues, newValues Bind, hasChanges bool)

func (Bind) Get added in v1.4.0

func (b Bind) Get(key string) any

type BindError added in v1.4.0

type BindError struct {
	Field   string
	Message string
}

func (*BindError) Error added in v1.4.0

func (b *BindError) Error() string

type ColumnSchemaDefinition added in v1.4.0

type ColumnSchemaDefinition struct {
	ColumnName string
	Definition string
}

type Context added in v1.4.2

type Context interface {
	Context() context.Context
	Clone() Context
	CloneWithContext(context context.Context) Context
	Engine() Engine
	Flush() error
	FlushAsync() error
	ClearFlush()
	RedisPipeLine(pool string) *RedisPipeLine
	RegisterQueryLogger(handler LogHandler, mysql, redis, local bool)
	EnableQueryDebug()
	EnableQueryDebugCustom(mysql, redis, local bool)
	SetMetaData(key, value string)
	GetMetaData() Meta
	// contains filtered or unexported methods
}

func PrepareTables added in v1.4.0

func PrepareTables(t *testing.T, registry Registry, entities ...any) (orm Context)

type DB

type DB interface {
	DBBase
	Begin(ctx Context) DBTransaction
}

type DBBase added in v1.4.0

type DBBase interface {
	GetConfig() MySQLConfig
	GetDBClient() DBClient
	SetMockDBClient(mock DBClient)
	Prepare(ctx Context, query string) (stmt PreparedStmt, close func())
	Exec(ctx Context, query string, args ...any) ExecResult
	QueryRow(ctx Context, query Where, toFill ...any) (found bool)
	Query(ctx Context, query string, args ...any) (rows Rows, close func())
}

type DBClient added in v1.4.0

type DBClient interface {
	DBClientQuery
}

type DBClientNoTX added in v1.4.0

type DBClientNoTX interface {
	DBClientQuery
	Begin() (*sql.Tx, error)
}

type DBClientQuery added in v1.4.0

type DBClientQuery interface {
	Prepare(query string) (*sql.Stmt, error)
	Exec(query string, args ...any) (sql.Result, error)
	ExecContext(context context.Context, query string, args ...any) (sql.Result, error)
	QueryRow(query string, args ...any) *sql.Row
	QueryRowContext(context context.Context, query string, args ...any) *sql.Row
	Query(query string, args ...any) (*sql.Rows, error)
	QueryContext(context context.Context, query string, args ...any) (*sql.Rows, error)
}

type DBTransaction added in v1.4.0

type DBTransaction interface {
	DBBase
	Commit(ctx Context)
	Rollback(ctx Context)
}

type Engine

type Engine interface {
	NewContext(parent context.Context) Context
	DB(code string) DB
	LocalCache(code string) LocalCache
	Redis(code string) RedisCache
	Registry() EngineRegistry
	Option(key string) any
}

type EngineRegistry added in v1.4.0

type EngineRegistry interface {
	EntitySchema(entity any) EntitySchema
	DBPools() map[string]DB
	LocalCachePools() map[string]LocalCache
	RedisPools() map[string]RedisCache
	Entities() []EntitySchema
	Option(key string) any
	Enums() map[string][]string
	// contains filtered or unexported methods
}

type EngineSetter added in v1.4.0

type EngineSetter interface {
	SetOption(key string, value any)
}

type EntityAnonymousIterator added in v1.4.0

type EntityAnonymousIterator interface {
	Next() bool
	ID() uint64
	Index() int
	Len() int
	Entity() any
	Reset()
}

type EntityFlush added in v1.4.0

type EntityFlush interface {
	ID() uint64
	Schema() *entitySchema
	// contains filtered or unexported methods
}

type EntityFlushedEvent added in v1.4.0

type EntityFlushedEvent interface {
	FlushType() FlushType
}

type EntityIterator added in v1.4.0

type EntityIterator[E any] interface {
	Next() bool
	ID() uint64
	Index() int
	Len() int
	Entity() *E
	All() []*E
	Reset()
	LoadReference(columns ...string)
}

func GetAll added in v1.4.0

func GetAll[E any](ctx Context) EntityIterator[E]

func GetByIDs added in v1.4.0

func GetByIDs[E any](ctx Context, ids ...uint64) EntityIterator[E]

func GetByIndex added in v1.4.0

func GetByIndex[E any](ctx Context, indexName string, attributes ...any) EntityIterator[E]

func GetByReference added in v1.4.0

func GetByReference[E any, I ID](ctx Context, referenceName string, id I) EntityIterator[E]
func Search[E any](ctx Context, where Where, pager *Pager) EntityIterator[E]

func SearchWithCount added in v1.4.0

func SearchWithCount[E any](ctx Context, where Where, pager *Pager) (results EntityIterator[E], totalRows int)

type EntitySchema added in v1.4.0

type EntitySchema interface {
	EntitySchemaShared
	DropTable(ctx Context)
	TruncateTable(ctx Context)
	UpdateSchema(ctx Context)
	UpdateSchemaAndTruncateTable(ctx Context)
	GetSchemaChanges(ctx Context) (alters []Alter, has bool)
	DisableCache(local, redis bool)
	NewEntity(ctx Context) any
	GetByID(ctx Context, id uint64) (entity any, found bool)
	Search(ctx Context, where Where, pager *Pager) EntityAnonymousIterator
	SearchWithCount(ctx Context, where Where, pager *Pager) (results EntityAnonymousIterator, totalRows int)
	SearchIDs(ctx Context, where Where, pager *Pager) []uint64
	SearchIDsWithCount(ctx Context, where Where, pager *Pager) (results []uint64, totalRows int)
	IsDirty(ctx Context, id uint64) (oldValues, newValues Bind, hasChanges bool)
	Copy(ctx Context, source any) any
	EditEntityField(ctx Context, entity any, field string, value any) error
	EditEntity(ctx Context, entity any) any
	DeleteEntity(ctx Context, entity any)
	// contains filtered or unexported methods
}

func GetEntitySchema added in v1.4.0

func GetEntitySchema[E any](ctx Context) EntitySchema

type EntitySchemaSetter added in v1.4.0

type EntitySchemaSetter interface {
	SetOption(key string, value any)
	EntitySchemaShared
}

type EntitySchemaShared added in v1.4.0

type EntitySchemaShared interface {
	GetTableName() string
	GetType() reflect.Type
	GetColumns() []string
	GetTag(field, key, trueValue, defaultValue string) string
	Option(key string) any
	GetUniqueIndexes() map[string][]string
	GetDB() DB
	GetLocalCache() (cache LocalCache, has bool)
	GetRedisCache() (cache RedisCache, has bool)
}

type EnumValues added in v1.4.0

type EnumValues interface {
	EnumValues() any
}

type ExecResult

type ExecResult interface {
	LastInsertId() uint64
	RowsAffected() uint64
}

type FlushEvent added in v1.4.0

type FlushEvent struct {
	SQL             string
	QueryAttributes []string
}

type FlushEventWithError added in v1.4.0

type FlushEventWithError struct {
	FlushEvent
	Error string
}

type FlushType added in v1.4.0

type FlushType int
const (
	Insert FlushType = iota
	Update
	Delete
)

type ID added in v1.4.0

type ID interface {
	int | uint | uint8 | uint16 | uint32 | uint64 | int8 | int16 | int32 | int64
}

type IDGetter added in v1.4.0

type IDGetter interface {
	GetID() uint64
}

type IndexSchemaDefinition added in v1.4.0

type IndexSchemaDefinition struct {
	Name       string
	Unique     bool
	Duplicated bool
	// contains filtered or unexported fields
}

func (*IndexSchemaDefinition) GetColumns added in v1.4.0

func (ti *IndexSchemaDefinition) GetColumns() []string

func (*IndexSchemaDefinition) SetColumns added in v1.4.0

func (ti *IndexSchemaDefinition) SetColumns(columns []string)

type LocalCache

type LocalCache interface {
	Set(ctx Context, key string, value any)
	Remove(ctx Context, key string)
	GetConfig() LocalCacheConfig
	Get(ctx Context, key string) (value any, ok bool)
	Clear(ctx Context)
	GetUsage() []LocalCacheUsage
	// contains filtered or unexported methods
}

type LocalCacheConfig

type LocalCacheConfig interface {
	GetCode() string
	GetLimit() int
	GetSchema() EntitySchema
}

type LocalCacheUsage added in v1.4.0

type LocalCacheUsage struct {
	Type      string
	Limit     uint64
	Used      uint64
	Evictions uint64
}

type Lock

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

func (*Lock) Refresh

func (l *Lock) Refresh(ctx Context, ttl time.Duration) bool

func (*Lock) Release

func (l *Lock) Release(ctx Context)

func (*Lock) TTL

func (l *Lock) TTL(ctx Context) time.Duration

type Locker

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

func (*Locker) MustObtain added in v1.6.1

func (l *Locker) MustObtain(ctx Context, key string, ttl time.Duration, waitTimeout time.Duration) *Lock

func (*Locker) Obtain

func (l *Locker) Obtain(ctx Context, key string, ttl time.Duration, waitTimeout time.Duration) (lock *Lock, obtained bool)

type LogEntity added in v1.4.0

type LogEntity[Entity any] struct {
	ID       uint64 `orm:"split_async_flush=log-entity"`
	EntityID uint64
	Date     time.Time `orm:"time"`
	Meta     []byte
	Before   []byte
	After    []byte
}

type LogHandler added in v1.4.0

type LogHandler interface {
	Handle(ctx Context, log map[string]any)
}

type Meta added in v1.4.0

type Meta map[string]string

func (Meta) Get added in v1.4.0

func (m Meta) Get(key string) string

type MockDBClient added in v1.4.0

type MockDBClient struct {
	OriginDB            DBClient
	PrepareMock         func(query string) (*sql.Stmt, error)
	ExecMock            func(query string, args ...any) (sql.Result, error)
	ExecContextMock     func(context context.Context, query string, args ...any) (sql.Result, error)
	QueryRowMock        func(query string, args ...any) *sql.Row
	QueryRowContextMock func(context context.Context, query string, args ...any) *sql.Row
	QueryMock           func(query string, args ...any) (*sql.Rows, error)
	QueryContextMock    func(context context.Context, query string, args ...any) (*sql.Rows, error)
	BeginMock           func() (*sql.Tx, error)
	CommitMock          func() error
	RollbackMock        func() error
}

func (*MockDBClient) Exec added in v1.4.0

func (m *MockDBClient) Exec(query string, args ...any) (sql.Result, error)

func (*MockDBClient) ExecContext added in v1.4.0

func (m *MockDBClient) ExecContext(context context.Context, query string, args ...any) (sql.Result, error)

func (*MockDBClient) Prepare added in v1.4.0

func (m *MockDBClient) Prepare(query string) (*sql.Stmt, error)

func (*MockDBClient) Query added in v1.4.0

func (m *MockDBClient) Query(query string, args ...any) (*sql.Rows, error)

func (*MockDBClient) QueryContext added in v1.4.0

func (m *MockDBClient) QueryContext(context context.Context, query string, args ...any) (*sql.Rows, error)

func (*MockDBClient) QueryRow added in v1.4.0

func (m *MockDBClient) QueryRow(query string, args ...any) *sql.Row

func (*MockDBClient) QueryRowContext added in v1.4.0

func (m *MockDBClient) QueryRowContext(context context.Context, query string, args ...any) *sql.Row

type MockLogHandler added in v1.4.0

type MockLogHandler struct {
	Logs []map[string]any
}

func (*MockLogHandler) Clear added in v1.4.0

func (h *MockLogHandler) Clear()

func (*MockLogHandler) Handle added in v1.4.0

func (h *MockLogHandler) Handle(_ Context, log map[string]any)

type MySQLConfig added in v1.4.0

type MySQLConfig interface {
	GetCode() string
	GetDatabaseName() string
	GetDataSourceURI() string
	GetOptions() *MySQLOptions
	// contains filtered or unexported methods
}

type MySQLOptions added in v1.4.0

type MySQLOptions struct {
	ConnMaxLifetime    time.Duration
	MaxOpenConnections int
	MaxIdleConnections int
	DefaultEncoding    string
	DefaultCollate     string
	IgnoredTables      []string
}

type Pager

type Pager struct {
	CurrentPage int
	PageSize    int
}

func NewPager

func NewPager(currentPage, pageSize int) *Pager

func (*Pager) GetCurrentPage

func (pager *Pager) GetCurrentPage() int

func (*Pager) GetPageSize

func (pager *Pager) GetPageSize() int

func (*Pager) IncrementPage

func (pager *Pager) IncrementPage()

func (*Pager) String added in v1.4.0

func (pager *Pager) String() string

type PipeLineBool

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

func (*PipeLineBool) Result

func (c *PipeLineBool) Result() bool

type PipeLineGet

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

func (*PipeLineGet) Result

func (c *PipeLineGet) Result() (value string, has bool)

type PipeLineInt

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

func (*PipeLineInt) Result

func (c *PipeLineInt) Result() int64

type PipeLineSlice added in v1.4.0

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

func (*PipeLineSlice) Result added in v1.4.0

func (c *PipeLineSlice) Result() []string

type PipeLineString

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

func (*PipeLineString) Result

func (c *PipeLineString) Result() string

type PluginInterfaceEntityFlush added in v1.4.0

type PluginInterfaceEntityFlush interface {
	EntityFlush(schema EntitySchema, entity reflect.Value, before, after Bind, engine Engine) (PostFlushAction, error)
}

type PluginInterfaceInitRegistryFromYaml added in v1.4.0

type PluginInterfaceInitRegistryFromYaml interface {
	InitRegistryFromYaml(registry Registry, yaml map[string]any) error
}

type PluginInterfaceValidateEntitySchema added in v1.4.0

type PluginInterfaceValidateEntitySchema interface {
	ValidateEntitySchema(schema EntitySchemaSetter) error
}

type PluginInterfaceValidateRegistry added in v1.4.0

type PluginInterfaceValidateRegistry interface {
	ValidateRegistry(engine EngineSetter, registry Registry) error
}

type PostFlushAction added in v1.4.0

type PostFlushAction func(ctx Context)

type PreparedStmt added in v1.4.0

type PreparedStmt interface {
	Exec(ctx Context, args ...any) ExecResult
	Query(ctx Context, args ...any) (rows Rows, close func())
	QueryRow(ctx Context, args []any, toFill ...any) (found bool)
	Close() error
}

type QueryLoggerSource

type QueryLoggerSource int

type RedisCache

type RedisCache interface {
	Set(ctx Context, key string, value any, expiration time.Duration)
	MSet(ctx Context, pairs ...any)
	Del(ctx Context, keys ...string)
	HSet(ctx Context, key string, values ...any)
	HDel(ctx Context, key string, keys ...string)
	GetSet(ctx Context, key string, expiration time.Duration, provider func() any) any
	Info(ctx Context, section ...string) string
	GetConfig() RedisPoolConfig
	Get(ctx Context, key string) (value string, has bool)
	Eval(ctx Context, script string, keys []string, args ...any) any
	EvalSha(ctx Context, sha1 string, keys []string, args ...any) (res any, exists bool)
	SetNX(ctx Context, key string, value any, expiration time.Duration) bool
	ScriptExists(ctx Context, sha1 string) bool
	ScriptLoad(ctx Context, script string) string
	LPush(ctx Context, key string, values ...any) int64
	LPop(ctx Context, key string) string
	RPush(ctx Context, key string, values ...any) int64
	LLen(ctx Context, key string) int64
	Exists(ctx Context, keys ...string) int64
	Type(ctx Context, key string) string
	LRange(ctx Context, key string, start, stop int64) []string
	LIndex(ctx Context, key string, index int64) (string, bool)
	LSet(ctx Context, key string, index int64, value any)
	RPop(ctx Context, key string) (value string, found bool)
	BLMove(ctx Context, source, destination, srcPos, destPos string, timeout time.Duration) string
	LMove(ctx Context, source, destination, srcPos, destPos string) string
	LRem(ctx Context, key string, count int64, value any)
	Ltrim(ctx Context, key string, start, stop int64)
	HSetNx(ctx Context, key, field string, value any) bool
	HMGet(ctx Context, key string, fields ...string) map[string]any
	HGetAll(ctx Context, key string) map[string]string
	HGet(ctx Context, key, field string) (value string, has bool)
	HLen(ctx Context, key string) int64
	HIncrBy(ctx Context, key, field string, incr int64) int64
	IncrBy(ctx Context, key string, incr int64) int64
	Incr(ctx Context, key string) int64
	IncrWithExpire(ctx Context, key string, expire time.Duration) int64
	Expire(ctx Context, key string, expiration time.Duration) bool
	ZAdd(ctx Context, key string, members ...redis.Z) int64
	ZRevRange(ctx Context, key string, start, stop int64) []string
	ZRevRangeWithScores(ctx Context, key string, start, stop int64) []redis.Z
	ZRangeWithScores(ctx Context, key string, start, stop int64) []redis.Z
	ZCard(ctx Context, key string) int64
	ZCount(ctx Context, key string, min, max string) int64
	ZScore(ctx Context, key, member string) float64
	MGet(ctx Context, keys ...string) []any
	SAdd(ctx Context, key string, members ...any) int64
	SMembers(ctx Context, key string) []string
	SIsMember(ctx Context, key string, member any) bool
	SCard(ctx Context, key string) int64
	SPop(ctx Context, key string) (string, bool)
	SPopN(ctx Context, key string, max int64) []string
	XTrim(ctx Context, stream string, maxLen int64) (deleted int64)
	XRange(ctx Context, stream, start, stop string, count int64) []redis.XMessage
	XRevRange(ctx Context, stream, start, stop string, count int64) []redis.XMessage
	XInfoStream(ctx Context, stream string) *redis.XInfoStream
	XInfoGroups(ctx Context, stream string) []redis.XInfoGroup
	XGroupCreate(ctx Context, stream, group, start string) (key string, exists bool)
	XGroupCreateMkStream(ctx Context, stream, group, start string) (key string, exists bool)
	XGroupDestroy(ctx Context, stream, group string) int64
	XRead(ctx Context, a *redis.XReadArgs) []redis.XStream
	XDel(ctx Context, stream string, ids ...string) int64
	XGroupDelConsumer(ctx Context, stream, group, consumer string) int64
	XReadGroup(ctx Context, a *redis.XReadGroupArgs) (streams []redis.XStream)
	XPending(ctx Context, stream, group string) *redis.XPending
	XPendingExt(ctx Context, a *redis.XPendingExtArgs) []redis.XPendingExt
	XLen(ctx Context, stream string) int64
	XClaim(ctx Context, a *redis.XClaimArgs) []redis.XMessage
	XClaimJustID(ctx Context, a *redis.XClaimArgs) []string
	XAck(ctx Context, stream, group string, ids ...string) int64
	FlushAll(ctx Context)
	FlushDB(ctx Context)
	GetLocker() *Locker
	Process(ctx Context, cmd redis.Cmder) error
	GetCode() string
}

type RedisOptions added in v1.4.0

type RedisOptions struct {
	User            string
	Password        string
	Master          string
	Sentinels       []string
	SentinelOptions *redis.FailoverOptions
}

type RedisPipeLine

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

func (*RedisPipeLine) Del

func (rp *RedisPipeLine) Del(key ...string)

func (*RedisPipeLine) Exec

func (rp *RedisPipeLine) Exec(ctx Context)

func (*RedisPipeLine) Expire

func (rp *RedisPipeLine) Expire(key string, expiration time.Duration) *PipeLineBool

func (*RedisPipeLine) Get

func (rp *RedisPipeLine) Get(key string) *PipeLineGet

func (*RedisPipeLine) HDel

func (rp *RedisPipeLine) HDel(key string, values ...string)

func (*RedisPipeLine) HIncrBy

func (rp *RedisPipeLine) HIncrBy(key, field string, incr int64) *PipeLineInt

func (*RedisPipeLine) HSet

func (rp *RedisPipeLine) HSet(key string, values ...any)

func (*RedisPipeLine) LPush added in v1.4.0

func (rp *RedisPipeLine) LPush(key string, values ...any)

func (*RedisPipeLine) LRange added in v1.4.0

func (rp *RedisPipeLine) LRange(key string, start, stop int64) *PipeLineSlice

func (*RedisPipeLine) LSet added in v1.4.0

func (rp *RedisPipeLine) LSet(key string, index int64, value any)

func (*RedisPipeLine) MSet added in v1.4.0

func (rp *RedisPipeLine) MSet(pairs ...any)

func (*RedisPipeLine) RPush added in v1.4.0

func (rp *RedisPipeLine) RPush(key string, values ...any)

func (*RedisPipeLine) SAdd added in v1.4.0

func (rp *RedisPipeLine) SAdd(key string, members ...any)

func (*RedisPipeLine) SRem added in v1.4.0

func (rp *RedisPipeLine) SRem(key string, members ...any)

func (*RedisPipeLine) Set

func (rp *RedisPipeLine) Set(key string, value any, expiration time.Duration)

func (*RedisPipeLine) XAdd

func (rp *RedisPipeLine) XAdd(stream string, values []string) *PipeLineString

type RedisPoolConfig added in v1.3.0

type RedisPoolConfig interface {
	GetCode() string
	GetDatabaseNumber() int
	GetAddress() string
	// contains filtered or unexported methods
}

type Reference added in v1.4.0

type Reference[E any] uint64

func (Reference[E]) GetEntity added in v1.4.0

func (r Reference[E]) GetEntity(ctx Context) *E

func (Reference[E]) GetID added in v1.4.0

func (r Reference[E]) GetID() uint64

func (Reference[E]) Schema added in v1.5.0

func (r Reference[E]) Schema(ctx Context) EntitySchema

type ReferenceInterface added in v1.5.0

type ReferenceInterface interface {
	IDGetter
	Schema(ctx Context) EntitySchema
	// contains filtered or unexported methods
}

type Registry

type Registry interface {
	Validate() (Engine, error)
	RegisterEntity(entity ...any)
	RegisterPlugin(plugin ...any)
	RegisterMySQL(dataSourceName string, poolCode string, poolOptions *MySQLOptions)
	RegisterLocalCache(code string, limit int)
	RegisterRedis(address string, db int, poolCode string, options *RedisOptions)
	InitByYaml(yaml any) error
	SetOption(key string, value any)
}

func NewRegistry added in v1.2.7

func NewRegistry() Registry

type Rows

type Rows interface {
	Next() bool
	Scan(dest ...any)
	Columns() []string
}

type SQLRow

type SQLRow interface {
	Scan(dest ...any) error
}

type SQLRows

type SQLRows interface {
	Next() bool
	Err() error
	Close() error
	Scan(dest ...any) error
	Columns() ([]string, error)
}

type TXClient added in v1.4.0

type TXClient interface {
	DBClientQuery
}

type TableSQLSchemaDefinition added in v1.4.0

type TableSQLSchemaDefinition struct {
	EntitySchema   EntitySchema
	EntityColumns  []*ColumnSchemaDefinition
	EntityIndexes  []*IndexSchemaDefinition
	DBTableColumns []*ColumnSchemaDefinition
	DBIndexes      []*IndexSchemaDefinition
	DBCreateSchema string
	DBEncoding     string
	Engine         string
	PreAlters      []Alter
	PostAlters     []Alter
	// contains filtered or unexported fields
}

func (*TableSQLSchemaDefinition) CreateTableSQL added in v1.4.0

func (td *TableSQLSchemaDefinition) CreateTableSQL() string

type Where

type Where interface {
	String() string
	GetParameters() []any
}

Directories

Path Synopsis
plugins

Jump to

Keyboard shortcuts

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