Documentation ¶
Overview ¶
Package beeorm keeps main code od BeeORM
Index ¶
- Constants
- func ConsumeAsyncBuffer(orm ORM, errF func(err error)) (stop func())
- func ConsumeAsyncFlushEvents(orm ORM, block bool) error
- func Copy[E any](orm ORM, source E) E
- func DeleteEntity[E any](orm ORM, source E)
- func EditEntity[E any](orm ORM, source E) E
- func EditEntityField(orm ORM, entity any, field string, value any) error
- func GetByID[E any, I ID](orm ORM, id I) (entity *E, found bool)
- func GetByUniqueIndex[E any](orm ORM, indexName string, attributes ...any) (entity *E, found bool)
- func MustByID[E any, I ID](orm ORM, id I) *E
- func NewEntity[E any](orm ORM) *E
- func SearchIDs[E any](orm ORM, where Where, pager *Pager) []uint64
- func SearchIDsWithCount[E any](orm ORM, where Where, pager *Pager) (results []uint64, totalRows int)
- func SearchOne[E any](orm ORM, where Where) (entity *E, found bool)
- type Alter
- type AsyncFlushEvents
- type BaseWhere
- type Bind
- type BindError
- type ColumnSchemaDefinition
- type DB
- type DBBase
- type DBClient
- type DBClientNoTX
- type DBClientQuery
- type DBTransaction
- type Engine
- type EngineRegistry
- type EngineSetter
- type EntityAnonymousIterator
- type EntityFlush
- type EntityFlushedEvent
- type EntityIterator
- func GetAll[E any](orm ORM) EntityIterator[E]
- func GetByIDs[E any](orm ORM, ids ...uint64) EntityIterator[E]
- func GetByIndex[E any](orm ORM, indexName string, attributes ...any) EntityIterator[E]
- func GetByReference[E any, I ID](orm ORM, referenceName string, id I) EntityIterator[E]
- func Search[E any](orm ORM, where Where, pager *Pager) EntityIterator[E]
- func SearchWithCount[E any](orm ORM, where Where, pager *Pager) (results EntityIterator[E], totalRows int)
- type EntitySchema
- type EntitySchemaSetter
- type EntitySchemaShared
- type EnumValues
- type ExecResult
- type FlushEvent
- type FlushEventWithError
- type FlushType
- type ID
- type IDGetter
- type IndexSchemaDefinition
- type LocalCache
- type LocalCacheConfig
- type LocalCacheUsage
- type Lock
- type Locker
- type LogEntity
- type LogHandler
- type Meta
- type MockDBClient
- func (m *MockDBClient) Exec(query string, args ...any) (sql.Result, error)
- func (m *MockDBClient) ExecContext(context context.Context, query string, args ...any) (sql.Result, error)
- func (m *MockDBClient) Prepare(query string) (*sql.Stmt, error)
- func (m *MockDBClient) Query(query string, args ...any) (*sql.Rows, error)
- func (m *MockDBClient) QueryContext(context context.Context, query string, args ...any) (*sql.Rows, error)
- func (m *MockDBClient) QueryRow(query string, args ...any) *sql.Row
- func (m *MockDBClient) QueryRowContext(context context.Context, query string, args ...any) *sql.Row
- type MockLogHandler
- type MySQLConfig
- type MySQLOptions
- type ORM
- type Pager
- type PipeLineBool
- type PipeLineGet
- type PipeLineInt
- type PipeLineSlice
- type PipeLineString
- type PluginInterfaceEntityFlush
- type PluginInterfaceInitRegistryFromYaml
- type PluginInterfaceValidateEntitySchema
- type PluginInterfaceValidateRegistry
- type PostFlushAction
- type PreparedStmt
- type QueryLoggerSource
- type RedisCache
- type RedisOptions
- type RedisPipeLine
- func (rp *RedisPipeLine) Del(key ...string)
- func (rp *RedisPipeLine) Exec(orm ORM)
- func (rp *RedisPipeLine) Expire(key string, expiration time.Duration) *PipeLineBool
- func (rp *RedisPipeLine) Get(key string) *PipeLineGet
- func (rp *RedisPipeLine) HDel(key string, values ...string)
- func (rp *RedisPipeLine) HIncrBy(key, field string, incr int64) *PipeLineInt
- func (rp *RedisPipeLine) HSet(key string, values ...any)
- func (rp *RedisPipeLine) LPush(key string, values ...any)
- func (rp *RedisPipeLine) LRange(key string, start, stop int64) *PipeLineSlice
- func (rp *RedisPipeLine) LSet(key string, index int64, value any)
- func (rp *RedisPipeLine) MSet(pairs ...any)
- func (rp *RedisPipeLine) RPush(key string, values ...any)
- func (rp *RedisPipeLine) SAdd(key string, members ...any)
- func (rp *RedisPipeLine) SRem(key string, members ...any)
- func (rp *RedisPipeLine) Set(key string, value any, expiration time.Duration)
- func (rp *RedisPipeLine) XAdd(stream string, values []string) *PipeLineString
- type RedisPoolConfig
- type Reference
- type Registry
- type Rows
- type SQLRow
- type SQLRows
- type TXClient
- type TableSQLSchemaDefinition
- type Where
Constants ¶
View Source
const DefaultPoolCode = "default"
Variables ¶
This section is empty.
Functions ¶
func ConsumeAsyncBuffer ¶ added in v3.1.1
func ConsumeAsyncFlushEvents ¶
func DeleteEntity ¶
func EditEntity ¶
func EditEntityField ¶ added in v3.1.1
func GetByUniqueIndex ¶
func SearchIDsWithCount ¶
Types ¶
type AsyncFlushEvents ¶
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 ¶
func ReadAsyncFlushEvents(orm ORM) []AsyncFlushEvents
type BaseWhere ¶ added in v3.5.0
type BaseWhere struct {
// contains filtered or unexported fields
}
func (*BaseWhere) GetParameters ¶ added in v3.5.0
func (*BaseWhere) SetParameter ¶ added in v3.5.0
func (*BaseWhere) SetParameters ¶ added in v3.5.0
type ColumnSchemaDefinition ¶
type DB ¶
type DB interface { DBBase Begin(orm ORM) DBTransaction }
type DBBase ¶
type DBBase interface { GetConfig() MySQLConfig GetDBClient() DBClient SetMockDBClient(mock DBClient) Prepare(orm ORM, query string) (stmt PreparedStmt, close func()) Exec(orm ORM, query string, args ...any) ExecResult QueryRow(orm ORM, query Where, toFill ...any) (found bool) Query(orm ORM, query string, args ...any) (rows Rows, close func()) }
type DBClient ¶
type DBClient interface { DBClientQuery }
type DBClientNoTX ¶
type DBClientNoTX interface { DBClientQuery Begin() (*sql.Tx, error) }
type DBClientQuery ¶
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 ¶
type Engine ¶
type Engine interface { NewORM(parent context.Context) ORM DB(code string) DB LocalCache(code string) LocalCache Redis(code string) RedisCache Registry() EngineRegistry Option(key string) any }
type EngineRegistry ¶
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 v3.1.0
type EntityAnonymousIterator ¶ added in v3.2.0
type EntityFlush ¶
type EntityFlush interface { ID() uint64 Schema() *entitySchema // contains filtered or unexported methods }
type EntityFlushedEvent ¶
type EntityFlushedEvent interface {
FlushType() FlushType
}
type EntityIterator ¶
type EntityIterator[E any] interface { Next() bool ID() uint64 Index() int Len() int Entity() *E All() []*E Reset() LoadReference(columns ...string) }
func GetAll ¶
func GetAll[E any](orm ORM) EntityIterator[E]
func GetByIndex ¶ added in v3.7.1
func GetByIndex[E any](orm ORM, indexName string, attributes ...any) EntityIterator[E]
func GetByReference ¶
func GetByReference[E any, I ID](orm ORM, referenceName string, id I) EntityIterator[E]
func SearchWithCount ¶
type EntitySchema ¶
type EntitySchema interface { EntitySchemaShared DropTable(orm ORM) TruncateTable(orm ORM) UpdateSchema(orm ORM) UpdateSchemaAndTruncateTable(orm ORM) GetSchemaChanges(orm ORM) (alters []Alter, has bool) DisableCache(local, redis bool) NewEntity(orm ORM) any GetByID(orm ORM, id uint64) (entity any, found bool) Search(orm ORM, where Where, pager *Pager) EntityAnonymousIterator SearchWithCount(orm ORM, where Where, pager *Pager) (results EntityAnonymousIterator, totalRows int) SearchIDs(orm ORM, where Where, pager *Pager) []uint64 SearchIDsWithCount(orm ORM, where Where, pager *Pager) (results []uint64, totalRows int) IsDirty(orm ORM, id uint64) (oldValues, newValues Bind, hasChanges bool) Copy(orm ORM, source any) any EditEntityField(orm ORM, entity any, field string, value any) error EditEntity(orm ORM, entity any) any DeleteEntity(orm ORM, entity any) // contains filtered or unexported methods }
func GetEntitySchema ¶
func GetEntitySchema[E any](orm ORM) EntitySchema
type EntitySchemaSetter ¶ added in v3.1.0
type EntitySchemaSetter interface { SetOption(key string, value any) EntitySchemaShared }
type EntitySchemaShared ¶ added in v3.1.0
type EntitySchemaShared interface {}
type EnumValues ¶
type EnumValues interface {
EnumValues() any
}
type ExecResult ¶
type FlushEvent ¶
type FlushEventWithError ¶
type FlushEventWithError struct { FlushEvent Error string }
type IndexSchemaDefinition ¶
type IndexSchemaDefinition struct { Name string Unique bool Duplicated bool // contains filtered or unexported fields }
func (*IndexSchemaDefinition) GetColumns ¶
func (ti *IndexSchemaDefinition) GetColumns() []string
func (*IndexSchemaDefinition) SetColumns ¶
func (ti *IndexSchemaDefinition) SetColumns(columns []string)
type LocalCache ¶
type LocalCacheConfig ¶
type LocalCacheConfig interface { GetCode() string GetLimit() int GetSchema() EntitySchema }
type LocalCacheUsage ¶ added in v3.6.1
type LogHandler ¶
type MockDBClient ¶
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) ExecContext ¶
func (*MockDBClient) QueryContext ¶
func (*MockDBClient) QueryRowContext ¶
type MockLogHandler ¶
func (*MockLogHandler) Clear ¶
func (h *MockLogHandler) Clear()
type MySQLConfig ¶
type MySQLConfig interface { GetCode() string GetDatabaseName() string GetDataSourceURI() string GetOptions() *MySQLOptions // contains filtered or unexported methods }
type MySQLOptions ¶
type ORM ¶ added in v3.2.0
type ORM interface { Context() context.Context Clone() ORM CloneWithContext(context context.Context) ORM 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 }
type Pager ¶
func (*Pager) GetCurrentPage ¶
func (*Pager) GetPageSize ¶
func (*Pager) IncrementPage ¶
func (pager *Pager) IncrementPage()
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 ¶
type PipeLineSlice struct {
// contains filtered or unexported fields
}
func (*PipeLineSlice) Result ¶
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 v3.1.0
type PluginInterfaceEntityFlush interface {
EntityFlush(schema EntitySchema, entity reflect.Value, before, after Bind, engine Engine) (PostFlushAction, error)
}
type PluginInterfaceInitRegistryFromYaml ¶ added in v3.1.0
type PluginInterfaceValidateEntitySchema ¶ added in v3.1.0
type PluginInterfaceValidateEntitySchema interface {
ValidateEntitySchema(schema EntitySchemaSetter) error
}
type PluginInterfaceValidateRegistry ¶ added in v3.1.0
type PluginInterfaceValidateRegistry interface {
ValidateRegistry(engine EngineSetter, registry Registry) error
}
type PostFlushAction ¶ added in v3.1.0
type PostFlushAction func(orm ORM)
type PreparedStmt ¶
type QueryLoggerSource ¶
type QueryLoggerSource int
type RedisCache ¶
type RedisCache interface { Set(orm ORM, key string, value any, expiration time.Duration) MSet(orm ORM, pairs ...any) Del(orm ORM, keys ...string) HSet(orm ORM, key string, values ...any) HDel(orm ORM, key string, keys ...string) GetSet(orm ORM, key string, expiration time.Duration, provider func() any) any Info(orm ORM, section ...string) string GetConfig() RedisPoolConfig Get(orm ORM, key string) (value string, has bool) Eval(orm ORM, script string, keys []string, args ...any) any EvalSha(orm ORM, sha1 string, keys []string, args ...any) (res any, exists bool) SetNX(orm ORM, key string, value any, expiration time.Duration) bool ScriptExists(orm ORM, sha1 string) bool ScriptLoad(orm ORM, script string) string LPush(orm ORM, key string, values ...any) int64 LPop(orm ORM, key string) string RPush(orm ORM, key string, values ...any) int64 LLen(orm ORM, key string) int64 Exists(orm ORM, keys ...string) int64 Type(orm ORM, key string) string LRange(orm ORM, key string, start, stop int64) []string LSet(orm ORM, key string, index int64, value any) RPop(orm ORM, key string) (value string, found bool) BLMove(orm ORM, source, destination, srcPos, destPos string, timeout time.Duration) string LMove(orm ORM, source, destination, srcPos, destPos string) string LRem(orm ORM, key string, count int64, value any) Ltrim(orm ORM, key string, start, stop int64) HSetNx(orm ORM, key, field string, value any) bool HMGet(orm ORM, key string, fields ...string) map[string]any HGetAll(orm ORM, key string) map[string]string HGet(orm ORM, key, field string) (value string, has bool) HLen(orm ORM, key string) int64 HIncrBy(orm ORM, key, field string, incr int64) int64 IncrBy(orm ORM, key string, incr int64) int64 Incr(orm ORM, key string) int64 IncrWithExpire(orm ORM, key string, expire time.Duration) int64 Expire(orm ORM, key string, expiration time.Duration) bool ZAdd(orm ORM, key string, members ...redis.Z) int64 ZRevRange(orm ORM, key string, start, stop int64) []string ZRevRangeWithScores(orm ORM, key string, start, stop int64) []redis.Z ZRangeWithScores(orm ORM, key string, start, stop int64) []redis.Z ZCard(orm ORM, key string) int64 ZCount(orm ORM, key string, min, max string) int64 ZScore(orm ORM, key, member string) float64 MGet(orm ORM, keys ...string) []any SAdd(orm ORM, key string, members ...any) int64 SMembers(orm ORM, key string) []string SIsMember(orm ORM, key string, member any) bool SCard(orm ORM, key string) int64 SPop(orm ORM, key string) (string, bool) SPopN(orm ORM, key string, max int64) []string XTrim(orm ORM, stream string, maxLen int64) (deleted int64) XRange(orm ORM, stream, start, stop string, count int64) []redis.XMessage XRevRange(orm ORM, stream, start, stop string, count int64) []redis.XMessage XInfoStream(orm ORM, stream string) *redis.XInfoStream XInfoGroups(orm ORM, stream string) []redis.XInfoGroup XGroupCreate(orm ORM, stream, group, start string) (key string, exists bool) XGroupCreateMkStream(orm ORM, stream, group, start string) (key string, exists bool) XGroupDestroy(orm ORM, stream, group string) int64 XRead(orm ORM, a *redis.XReadArgs) []redis.XStream XDel(orm ORM, stream string, ids ...string) int64 XGroupDelConsumer(orm ORM, stream, group, consumer string) int64 XReadGroup(orm ORM, a *redis.XReadGroupArgs) (streams []redis.XStream) XPending(orm ORM, stream, group string) *redis.XPending XPendingExt(orm ORM, a *redis.XPendingExtArgs) []redis.XPendingExt XLen(orm ORM, stream string) int64 XClaim(orm ORM, a *redis.XClaimArgs) []redis.XMessage XClaimJustID(orm ORM, a *redis.XClaimArgs) []string XAck(orm ORM, stream, group string, ids ...string) int64 FlushAll(orm ORM) FlushDB(orm ORM) GetLocker() *Locker Process(orm ORM, cmd redis.Cmder) error GetCode() string }
type RedisOptions ¶
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(orm ORM)
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 ¶
func (rp *RedisPipeLine) LPush(key string, values ...any)
func (*RedisPipeLine) LRange ¶
func (rp *RedisPipeLine) LRange(key string, start, stop int64) *PipeLineSlice
func (*RedisPipeLine) MSet ¶
func (rp *RedisPipeLine) MSet(pairs ...any)
func (*RedisPipeLine) RPush ¶
func (rp *RedisPipeLine) RPush(key string, values ...any)
func (*RedisPipeLine) SAdd ¶
func (rp *RedisPipeLine) SAdd(key string, members ...any)
func (*RedisPipeLine) SRem ¶
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 ¶
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 map[string]any) error SetOption(key string, value any) }
func NewRegistry ¶
func NewRegistry() Registry
type TXClient ¶
type TXClient interface { DBClientQuery }
type TableSQLSchemaDefinition ¶
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 ¶
func (td *TableSQLSchemaDefinition) CreateTableSQL() string
Source Files ¶
- bind.go
- column_setter.go
- copy.go
- db.go
- edit_entity_field.go
- editable_entity.go
- engine.go
- entity_deserialize.go
- entity_iterator.go
- entity_schema.go
- enum.go
- flush.go
- flush_async_buffer.go
- flush_async_consumer.go
- get_all.go
- get_by_id.go
- get_by_ids.go
- get_by_index.go
- get_by_reference.go
- get_by_unique_index.go
- local_cache.go
- locker.go
- log_table.go
- orm.go
- pager.go
- plugin.go
- query_logger.go
- read_flush_async_events.go
- redis_cache.go
- redis_pipeline.go
- reference.go
- registry.go
- schema.go
- search.go
- test.go
- utils.go
- where.go
- yaml_loader.go
Click to show internal directories.
Click to hide internal directories.