Documentation
¶
Index ¶
- Variables
- type BasicTable
- type Column
- type ColumnFieldExprType
- type Context
- type DB
- type DeleteContext
- func (c *DeleteContext[T]) Do(db DB) (rowsAffected int64, err error)
- func (c *DeleteContext[T]) DoCtx(ctx context.Context, db DB) (rowsAffected int64, err error)
- func (c *DeleteContext[T]) Limit(limit uint64) *DeleteContext[T]
- func (c *DeleteContext[T]) OrderBy(direction OrderDirection, expr TableExpr[T]) *DeleteContext[T]
- func (c *DeleteContext[T]) Where(condition TypedTableExpr[T, WrappedPrimitive[bool]]) *DeleteContext[T]
- type Expr
- type ExprPrimitive
- type ExprStruct
- type ExprType
- type InsertContext
- func (c *InsertContext[T]) Do(db DB) (rowsAffected int64, err error)
- func (c *InsertContext[T]) DoCtx(ctx context.Context, db DB) (rowsAffected int64, err error)
- func (c *InsertContext[T]) Fields(fields ...TableColumns[T]) *InsertContext[T]
- func (c *InsertContext[T]) Values(tableBases ...T) *InsertContext[T]
- type JoinedTable
- type LockType
- type OrderDirection
- type PluckContext
- func (c *PluckContext[T, S]) Distinct() *PluckContext[T, S]
- func (c *PluckContext[T, S]) Get(db DB) (S, error)
- func (c *PluckContext[T, S]) GetAll(db DB) ([]S, error)
- func (c *PluckContext[T, S]) GetAllCtx(ctx context.Context, db DB) ([]S, error)
- func (c *PluckContext[T, S]) GetCtx(ctx context.Context, db DB) (S, error)
- func (c *PluckContext[T, S]) GroupBy(exprs ...TableExpr[T]) *PluckContext[T, S]
- func (c *PluckContext[T, S]) Having(condition TypedTableExpr[T, WrappedPrimitive[bool]]) *PluckContext[T, S]
- func (c *PluckContext[T, S]) Limit(limit uint64) *PluckContext[T, S]
- func (c *PluckContext[T, S]) Lock(lockType LockType) *PluckContext[T, S]
- func (c *PluckContext[T, S]) Offset(offset uint64) *PluckContext[T, S]
- func (c *PluckContext[T, S]) OrderBy(direction OrderDirection, expr TableExpr[T]) *PluckContext[T, S]
- func (c *PluckContext[T, S]) Where(condition TypedTableExpr[T, WrappedPrimitive[bool]]) *PluckContext[T, S]
- type Ref
- type SelectContext
- func (c *SelectContext[T]) Distinct() *SelectContext[T]
- func (c *SelectContext[T]) Fields(fields ...TableColumns[T]) *SelectContext[T]
- func (c *SelectContext[T]) Get(db DB) (T, error)
- func (c *SelectContext[T]) GetAll(db DB) ([]T, error)
- func (c *SelectContext[T]) GetAllCtx(ctx context.Context, db DB) ([]T, error)
- func (c *SelectContext[T]) GetCtx(ctx context.Context, db DB) (T, error)
- func (c *SelectContext[T]) GroupBy(exprs ...TableExpr[T]) *SelectContext[T]
- func (c *SelectContext[T]) Having(condition TypedTableExpr[T, WrappedPrimitive[bool]]) *SelectContext[T]
- func (c *SelectContext[T]) Limit(limit uint64) *SelectContext[T]
- func (c *SelectContext[T]) Lock(lockType LockType) *SelectContext[T]
- func (c *SelectContext[T]) Offset(offset uint64) *SelectContext[T]
- func (c *SelectContext[T]) OrderBy(direction OrderDirection, expr TableExpr[T]) *SelectContext[T]
- func (c *SelectContext[T]) Where(condition TypedTableExpr[T, WrappedPrimitive[bool]]) *SelectContext[T]
- type Table
- type TableAssignExpr
- type TableColumns
- type TableExpr
- type TypedColumns
- type TypedExpr
- type TypedTableColumns
- type TypedTableExpr
- func And[T Table](expr1 TypedTableExpr[T, WrappedPrimitive[bool]], ...) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Avg[T Table, S ExprType](expr TypedTableExpr[T, S], distinct bool) TypedTableExpr[T, WrappedPrimitive[float64]]
- func Count[T Table, S ExprType](expr TypedTableExpr[T, S], distinct bool) TypedTableExpr[T, WrappedPrimitive[int64]]
- func Eq[T Table, S ExprType](expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func EqLit[T Table, S ExprType](expr TypedTableExpr[T, S], literal S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Geq[T Table, S ExprType](expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func GeqLit[T Table, S ExprType](expr TypedTableExpr[T, S], literal S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Gt[T Table, S ExprType](expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func GtLit[T Table, S ExprType](expr TypedTableExpr[T, S], literal S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func In[T Table, S ExprType](expr1 TypedTableExpr[T, S], exprs ...TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func InLit[T Table, S ExprType](expr TypedTableExpr[T, S], literals ...S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func IsNotNull[T Table, S ExprType](expr TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func IsNull[T Table, S ExprType](expr TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Leq[T Table, S ExprType](expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func LeqLit[T Table, S ExprType](expr TypedTableExpr[T, S], literal S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Lt[T Table, S ExprType](expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func LtLit[T Table, S ExprType](expr TypedTableExpr[T, S], literal S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Max[T Table, S ExprType](expr TypedTableExpr[T, S]) TypedTableExpr[T, S]
- func Min[T Table, S ExprType](expr TypedTableExpr[T, S]) TypedTableExpr[T, S]
- func Neq[T Table, S ExprType](expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func NeqLit[T Table, S ExprType](expr TypedTableExpr[T, S], literal S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Not[T Table](expr TypedTableExpr[T, WrappedPrimitive[bool]]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func NotIn[T Table, S ExprType](expr1 TypedTableExpr[T, S], exprs ...TypedTableExpr[T, S]) TypedTableExpr[T, WrappedPrimitive[bool]]
- func NotInLit[T Table, S ExprType](expr TypedTableExpr[T, S], literals ...S) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Or[T Table](expr1 TypedTableExpr[T, WrappedPrimitive[bool]], ...) TypedTableExpr[T, WrappedPrimitive[bool]]
- func Xor[T Table](expr1 TypedTableExpr[T, WrappedPrimitive[bool]], ...) TypedTableExpr[T, WrappedPrimitive[bool]]
- type UpdateContext
- func (c *UpdateContext[T]) Do(db DB) (rowsAffected int64, err error)
- func (c *UpdateContext[T]) DoCtx(ctx context.Context, db DB) (rowsAffected int64, err error)
- func (c *UpdateContext[T]) Limit(limit uint64) *UpdateContext[T]
- func (c *UpdateContext[T]) OrderBy(direction OrderDirection, expr TableExpr[T]) *UpdateContext[T]
- func (c *UpdateContext[T]) Set(assignExprs ...*TableAssignExpr[T]) (res *UpdateContext[T])
- func (c *UpdateContext[T]) Where(condition TypedTableExpr[T, WrappedPrimitive[bool]]) *UpdateContext[T]
- type WrappedPrimitive
Constants ¶
This section is empty.
Variables ¶
var ( ErrRecordNotFound = errors.New("record not found") ErrNullValue = errors.New("null value") )
Functions ¶
This section is empty.
Types ¶
type BasicTable ¶
type DeleteContext ¶
type DeleteContext[T BasicTable] struct { *Context[T] // contains filtered or unexported fields }
func Delete ¶
func Delete[T BasicTable](table T) *DeleteContext[T]
func (*DeleteContext[T]) Limit ¶
func (c *DeleteContext[T]) Limit(limit uint64) *DeleteContext[T]
func (*DeleteContext[T]) OrderBy ¶
func (c *DeleteContext[T]) OrderBy(direction OrderDirection, expr TableExpr[T]) *DeleteContext[T]
func (*DeleteContext[T]) Where ¶
func (c *DeleteContext[T]) Where( condition TypedTableExpr[T, WrappedPrimitive[bool]], ) *DeleteContext[T]
type ExprPrimitive ¶
type ExprStruct ¶
type InsertContext ¶
type InsertContext[T BasicTable] struct { *Context[T] // contains filtered or unexported fields }
func Insert ¶
func Insert[T BasicTable](table T) *InsertContext[T]
func (*InsertContext[T]) Fields ¶
func (c *InsertContext[T]) Fields(fields ...TableColumns[T]) *InsertContext[T]
func (*InsertContext[T]) Values ¶
func (c *InsertContext[T]) Values(tableBases ...T) *InsertContext[T]
type JoinedTable ¶
type JoinedTable interface {
Table
BaseTables() []BasicTable
AddError(error)
}
type PluckContext ¶
type PluckContext[T Table, S ExprType] struct { *Context[T] // contains filtered or unexported fields }
func Pluck ¶
func Pluck[T Table, S ExprType](table T, field TypedTableExpr[T, S]) *PluckContext[T, S]
func (*PluckContext[T, S]) Distinct ¶
func (c *PluckContext[T, S]) Distinct() *PluckContext[T, S]
func (*PluckContext[T, S]) Get ¶
func (c *PluckContext[T, S]) Get(db DB) (S, error)
func (*PluckContext[T, S]) GetAll ¶
func (c *PluckContext[T, S]) GetAll(db DB) ([]S, error)
func (*PluckContext[T, S]) GetAllCtx ¶
func (c *PluckContext[T, S]) GetAllCtx(ctx context.Context, db DB) ([]S, error)
func (*PluckContext[T, S]) GetCtx ¶
func (c *PluckContext[T, S]) GetCtx(ctx context.Context, db DB) (S, error)
func (*PluckContext[T, S]) GroupBy ¶
func (c *PluckContext[T, S]) GroupBy(exprs ...TableExpr[T]) *PluckContext[T, S]
func (*PluckContext[T, S]) Having ¶
func (c *PluckContext[T, S]) Having( condition TypedTableExpr[T, WrappedPrimitive[bool]], ) *PluckContext[T, S]
func (*PluckContext[T, S]) Limit ¶
func (c *PluckContext[T, S]) Limit(limit uint64) *PluckContext[T, S]
func (*PluckContext[T, S]) Lock ¶
func (c *PluckContext[T, S]) Lock(lockType LockType) *PluckContext[T, S]
func (*PluckContext[T, S]) Offset ¶
func (c *PluckContext[T, S]) Offset(offset uint64) *PluckContext[T, S]
func (*PluckContext[T, S]) OrderBy ¶
func (c *PluckContext[T, S]) OrderBy(direction OrderDirection, expr TableExpr[T]) *PluckContext[T, S]
func (*PluckContext[T, S]) Where ¶
func (c *PluckContext[T, S]) Where( condition TypedTableExpr[T, WrappedPrimitive[bool]], ) *PluckContext[T, S]
type SelectContext ¶
func Select ¶
func Select[T Table](table T) *SelectContext[T]
func (*SelectContext[T]) Distinct ¶
func (c *SelectContext[T]) Distinct() *SelectContext[T]
func (*SelectContext[T]) Fields ¶
func (c *SelectContext[T]) Fields(fields ...TableColumns[T]) *SelectContext[T]
func (*SelectContext[T]) Get ¶
func (c *SelectContext[T]) Get(db DB) (T, error)
func (*SelectContext[T]) GetAll ¶
func (c *SelectContext[T]) GetAll(db DB) ([]T, error)
func (*SelectContext[T]) GetAllCtx ¶
func (c *SelectContext[T]) GetAllCtx(ctx context.Context, db DB) ([]T, error)
func (*SelectContext[T]) GetCtx ¶
func (c *SelectContext[T]) GetCtx(ctx context.Context, db DB) (T, error)
func (*SelectContext[T]) GroupBy ¶
func (c *SelectContext[T]) GroupBy(exprs ...TableExpr[T]) *SelectContext[T]
func (*SelectContext[T]) Having ¶
func (c *SelectContext[T]) Having( condition TypedTableExpr[T, WrappedPrimitive[bool]], ) *SelectContext[T]
func (*SelectContext[T]) Limit ¶
func (c *SelectContext[T]) Limit(limit uint64) *SelectContext[T]
func (*SelectContext[T]) Lock ¶
func (c *SelectContext[T]) Lock(lockType LockType) *SelectContext[T]
func (*SelectContext[T]) Offset ¶
func (c *SelectContext[T]) Offset(offset uint64) *SelectContext[T]
func (*SelectContext[T]) OrderBy ¶
func (c *SelectContext[T]) OrderBy(direction OrderDirection, expr TableExpr[T]) *SelectContext[T]
func (*SelectContext[T]) Where ¶
func (c *SelectContext[T]) Where( condition TypedTableExpr[T, WrappedPrimitive[bool]], ) *SelectContext[T]
type TableAssignExpr ¶
type TableAssignExpr[T Table] struct { // contains filtered or unexported fields }
func Assign ¶
func Assign[T Table, S ExprType]( expr1 TypedTableColumns[T, S], expr2 TypedTableExpr[T, S], ) *TableAssignExpr[T]
Assign expr1 = expr2
func AssignLit ¶
func AssignLit[T Table, S ExprType]( expr TypedTableColumns[T, S], literal S, ) *TableAssignExpr[T]
AssignLit expr = literal
func (*TableAssignExpr[_]) AssignExpr ¶
func (tae *TableAssignExpr[_]) AssignExpr() (string, []ExprType, []error)
type TableColumns ¶
type TypedColumns ¶
type TypedTableColumns ¶
type TypedTableColumns[T Table, S ExprType] interface { TableColumns[T] TypedColumns[S] }
type TypedTableExpr ¶
func And ¶
func And[T Table]( expr1 TypedTableExpr[T, WrappedPrimitive[bool]], expr2 TypedTableExpr[T, WrappedPrimitive[bool]], ) TypedTableExpr[T, WrappedPrimitive[bool]]
And (expr1 AND expr2)
func Avg ¶
func Avg[T Table, S ExprType](expr TypedTableExpr[T, S], distinct bool) TypedTableExpr[T, WrappedPrimitive[float64]]
Avg if (distinct) {return AVG(DISTINCT expr)} else {return AVG(expr)}
func Count ¶
func Count[T Table, S ExprType](expr TypedTableExpr[T, S], distinct bool) TypedTableExpr[T, WrappedPrimitive[int64]]
Count if (distinct) {return COUNT(DISTINCT expr)} else {return COUNT(expr)}
func Eq ¶
func Eq[T Table, S ExprType]( expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Eq (expr1 = expr2)
func EqLit ¶
func EqLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literal S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
EqLit (expr = literal)
func Geq ¶
func Geq[T Table, S ExprType]( expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Geq (expr1 >= expr2)
func GeqLit ¶
func GeqLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literal S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
GeqLit (expr >= literal)
func Gt ¶
func Gt[T Table, S ExprType]( expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Gt (expr1 > expr2)
func GtLit ¶
func GtLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literal S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
GtLit (expr > literal)
func In ¶
func In[T Table, S ExprType]( expr1 TypedTableExpr[T, S], exprs ...TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
In (expr1 IN (exprs[0], exprs[1], ...))
func InLit ¶
func InLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literals ...S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
InLit (expr IN (literals[0], literal[1], ...))
func IsNotNull ¶
func IsNotNull[T Table, S ExprType]( expr TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
IsNotNull (expr IS NOT NULL)
func IsNull ¶
func IsNull[T Table, S ExprType]( expr TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
IsNull (expr IS NULL)
func Leq ¶
func Leq[T Table, S ExprType]( expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Leq (expr1 <= expr2)
func LeqLit ¶
func LeqLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literal S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
LeqLit (expr <= literal)
func Lt ¶
func Lt[T Table, S ExprType]( expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Lt (expr1 < expr2)
func LtLit ¶
func LtLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literal S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
LtLit (expr < literal)
func Max ¶
func Max[T Table, S ExprType](expr TypedTableExpr[T, S]) TypedTableExpr[T, S]
Max MAX(expr)
func Min ¶
func Min[T Table, S ExprType](expr TypedTableExpr[T, S]) TypedTableExpr[T, S]
Min MIN(expr)
func Neq ¶
func Neq[T Table, S ExprType]( expr1 TypedTableExpr[T, S], expr2 TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Neq (expr1 != expr2)
func NeqLit ¶
func NeqLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literal S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
NeqLit (expr != literal)
func Not ¶
func Not[T Table]( expr TypedTableExpr[T, WrappedPrimitive[bool]], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Not (NOT expr)
func NotIn ¶
func NotIn[T Table, S ExprType]( expr1 TypedTableExpr[T, S], exprs ...TypedTableExpr[T, S], ) TypedTableExpr[T, WrappedPrimitive[bool]]
NotIn (expr1 NOT IN (exprs[0], exprs[1], ...))
func NotInLit ¶
func NotInLit[T Table, S ExprType]( expr TypedTableExpr[T, S], literals ...S, ) TypedTableExpr[T, WrappedPrimitive[bool]]
NotInLit (expr NOT IN (literals[0], literal[1], ...))
func Or ¶
func Or[T Table]( expr1 TypedTableExpr[T, WrappedPrimitive[bool]], expr2 TypedTableExpr[T, WrappedPrimitive[bool]], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Or (expr1 OR expr2)
func Xor ¶
func Xor[T Table]( expr1 TypedTableExpr[T, WrappedPrimitive[bool]], expr2 TypedTableExpr[T, WrappedPrimitive[bool]], ) TypedTableExpr[T, WrappedPrimitive[bool]]
Xor (expr1 XOR expr2)
type UpdateContext ¶
func Update ¶
func Update[T Table](table T) *UpdateContext[T]
func (*UpdateContext[T]) Limit ¶
func (c *UpdateContext[T]) Limit(limit uint64) *UpdateContext[T]
func (*UpdateContext[T]) OrderBy ¶
func (c *UpdateContext[T]) OrderBy(direction OrderDirection, expr TableExpr[T]) *UpdateContext[T]
func (*UpdateContext[T]) Set ¶
func (c *UpdateContext[T]) Set(assignExprs ...*TableAssignExpr[T]) (res *UpdateContext[T])
func (*UpdateContext[T]) Where ¶
func (c *UpdateContext[T]) Where( condition TypedTableExpr[T, WrappedPrimitive[bool]], ) *UpdateContext[T]
type WrappedPrimitive ¶
type WrappedPrimitive[T ExprPrimitive] struct { // contains filtered or unexported fields }
func Wrap ¶
func Wrap[T ExprPrimitive](val T) WrappedPrimitive[T]
func (*WrappedPrimitive[T]) Scan ¶
func (wp *WrappedPrimitive[T]) Scan(src any) error
func (WrappedPrimitive[T]) Val ¶
func (wp WrappedPrimitive[T]) Val() (T, bool)