Documentation
¶
Index ¶
- Variables
- func Count[T any](ctx context.Context, opts FindOptions) (int64, error)
- func CountByBean(ctx context.Context, bean any) (int64, error)
- func Delete[T any](ctx context.Context, opts FindOptions) (int64, error)
- func DeleteByBean(ctx context.Context, bean any) (int64, error)
- func DeleteByBeans(ctx context.Context, beans ...any) (err error)
- func DeleteByID[T any](ctx context.Context, id int64) (int64, error)
- func DeleteByIDs[T any](ctx context.Context, ids ...int64) error
- func Exec(ctx context.Context, sqlAndArgs ...any) (sql.Result, error)
- func Exist[T any](ctx context.Context, cond builder.Cond) (bool, error)
- func ExistByID[T any](ctx context.Context, id int64) (bool, error)
- func Find[T any](ctx context.Context, opts FindOptions) ([]*T, error)
- func FindAndCount[T any](ctx context.Context, opts FindOptions) ([]*T, int64, error)
- func FindIDs(ctx context.Context, tableName, idCol string, cond builder.Cond) ([]int64, error)
- func Get[T any](ctx context.Context, cond builder.Cond) (object *T, exist bool, err error)
- func GetByID[T any](ctx context.Context, id int64) (object *T, exist bool, err error)
- func GetXORMEngine() *xorm.Engine
- func InTransaction(ctx context.Context) bool
- func Insert(ctx context.Context, beans ...any) error
- func SetDefaultFindSliceSize(size int)
- func SetXORMEngine(engine *xorm.Engine)
- func TruncateBeans(ctx context.Context, beans ...any) (err error)
- func WithTx(parentCtx context.Context, f func(ctx context.Context) error) error
- func WithTx2[T any](parentCtx context.Context, f func(ctx context.Context) (T, error)) (ret T, errRet error)
- type Committer
- type Engine
- type FindOptions
- type FindOptionsJoin
- type FindOptionsOrder
- type JoinFunc
Constants ¶
This section is empty.
Variables ¶
var IsProd = true
Functions ¶
func CountByBean ¶
CountByBean counts the number of database records according non-empty fields of the bean as conditions.
func DeleteByBean ¶
DeleteByBean deletes all records according non-empty fields of the bean as conditions.
func DeleteByBeans ¶
DeleteByBeans deletes all given beans, beans must contain delete conditions.
func DeleteByID ¶
DeleteByID deletes the given bean with the given ID
func Find ¶
func Find[T any](ctx context.Context, opts FindOptions) ([]*T, error)
Find represents a common find function which accept an options interface
func FindAndCount ¶
FindAndCount represents a common findandcount function which accept an options interface
func FindIDs ¶
FindIDs finds the IDs for the given table name satisfying the given condition By passing a different value than "id" for "idCol", you can query for foreign IDs, i.e. the repo IDs which satisfy the condition
func GetXORMEngine ¶
func InTransaction ¶
InTransaction returns true if the engine is in a transaction otherwise return false
func SetDefaultFindSliceSize ¶
func SetDefaultFindSliceSize(size int)
func SetXORMEngine ¶
func TruncateBeans ¶
TruncateBeans deletes all given beans, beans may contain delete conditions.
Types ¶
type Engine ¶
type Engine interface { Table(tableNameOrBean any) *xorm.Session Count(...any) (int64, error) Decr(column string, arg ...any) *xorm.Session Delete(...any) (int64, error) Truncate(...any) (int64, error) Exec(...any) (sql.Result, error) Find(any, ...any) error Get(beans ...any) (bool, error) ID(any) *xorm.Session In(string, ...any) *xorm.Session Incr(column string, arg ...any) *xorm.Session Insert(...any) (int64, error) Iterate(any, xorm.IterFunc) error Join(joinOperator string, tablename, condition any, args ...any) *xorm.Session SQL(any, ...any) *xorm.Session Where(any, ...any) *xorm.Session Asc(colNames ...string) *xorm.Session Desc(colNames ...string) *xorm.Session Limit(limit int, start ...int) *xorm.Session NoAutoTime() *xorm.Session SumInt(bean any, columnName string) (res int64, err error) Sync(...any) error Select(string) *xorm.Session SetExpr(string, any) *xorm.Session NotIn(string, ...any) *xorm.Session OrderBy(any, ...any) *xorm.Session Exist(...any) (bool, error) Distinct(...string) *xorm.Session Query(...any) ([]map[string][]byte, error) Cols(...string) *xorm.Session Context(ctx context.Context) *xorm.Session Ping() error IsTableExist(tableNameOrBean any) (bool, error) }
Engine represents a xorm engine or session.
type FindOptions ¶
type FindOptions interface { GetPage() int GetPageSize() int IsListAll() bool ToConds() builder.Cond }
FindOptions represents a find options
type FindOptionsJoin ¶
type FindOptionsJoin interface {
ToJoins() []JoinFunc
}
type FindOptionsOrder ¶
type FindOptionsOrder interface {
ToOrders() string
}