Documentation
¶
Index ¶
- Constants
- Variables
- func ExecSQL(rail miso.Rail, db *gorm.DB, sql string, args ...any) error
- func GetDB() *gorm.DB
- func ImplGetPrimaryDBFunc(impl func() *gorm.DB) (implSet bool)
- func InitSchema(rail miso.Rail, initSchemaSegments []string, getDB func() *gorm.DB) error
- func InitSchemaConditionally(rail miso.Rail, conditionalSegments []ConditionalSchemaSegment, ...) error
- func IterateAllByOffset[V any, T any](rail miso.Rail, db *gorm.DB, p IterateByOffsetParam[V, T]) error
- func NewGormLogger(config lg.Config) *gormLogger
- func NewQueryFunc(table string, ops ...func(q *Query) *Query) func(r miso.Rail, db *gorm.DB) *Query
- func RunTransaction(rail miso.Rail, db *gorm.DB, callback func(qry func() *Query) error) error
- type ChainedPageQuery
- type ConditionalSchemaSegment
- type IterateByOffsetParam
- type IteratePageParam
- type MisoJSONSerializer
- type Nilable
- type NilableValue
- type PageQuery
- func (pq *PageQuery[V]) IterateAll(rail miso.Rail, param IteratePageParam, ...) error
- func (pq *PageQuery[V]) IterateAllPages(rail miso.Rail, param IteratePageParam, ...) error
- func (pq *PageQuery[V]) Scan(rail miso.Rail, reqPage miso.Paging) (miso.PageRes[V], error)
- func (pq *PageQuery[V]) Transform(t util.Transform[V]) *PageQuery[V]
- func (pq *PageQuery[V]) TransformAsync(t util.TransformAsync[V]) *PageQuery[V]
- func (pq *PageQuery[V]) WithBaseQuery(qry ChainedPageQuery) *PageQuery[V]
- func (pq *PageQuery[V]) WithSelectQuery(qry ChainedPageQuery) *PageQuery[V]
- type Query
- func (q *Query) And(f func(*Query) *Query) *Query
- func (q *Query) Between(col string, args ...any) *Query
- func (q *Query) ColumnName(s string) string
- func (q *Query) Count() (int64, error)
- func (q *Query) Create(v any) (rowsAffected int64, err error)
- func (q *Query) CreateAny(v any) error
- func (q *Query) CreateIgnore(v any) (rowsAffected int64, err error)
- func (q *Query) CreateIgnoreAny(v any) error
- func (q *Query) DB() *gorm.DB
- func (q *Query) Delete() (rowsAffected int64, err error)
- func (q *Query) DeleteAny() error
- func (q *Query) Eq(col string, args ...any) *Query
- func (q *Query) EqIf(cond bool, col string, args ...any) *Query
- func (q *Query) EqNotEmpty(col string, v any) *Query
- func (q *Query) Exec(sql string, args ...any) (rowsAffected int64, err error)
- func (q *Query) ExecAny(sql string, args ...any) error
- func (q *Query) From(table string) *Query
- func (q *Query) Ge(col string, args ...any) *Query
- func (q *Query) GeIf(cond bool, col string, args ...any) *Query
- func (q *Query) Group(name string) *Query
- func (q *Query) Gt(col string, args ...any) *Query
- func (q *Query) GtIf(cond bool, col string, args ...any) *Query
- func (q *Query) HasAny() (bool, error)
- func (q *Query) If(cond bool, f func(*Query) *Query) *Query
- func (q *Query) In(col string, args ...any) *Query
- func (q *Query) IsNotNull(col string) *Query
- func (q *Query) IsNull(col string) *Query
- func (q *Query) Join(query string, args ...any) *Query
- func (q *Query) JoinIf(addJoin bool, query string, args ...any) *Query
- func (q *Query) Joins(query string, args ...any) *Query
- func (q *Query) Le(col string, args ...any) *Query
- func (q *Query) LeIf(cond bool, col string, args ...any) *Query
- func (q *Query) Like(col string, val string) *Query
- func (q *Query) LikeIf(cond bool, col string, val string) *Query
- func (q *Query) LikeLeft(col string, val string) *Query
- func (q *Query) LikeLeftIf(cond bool, col string, val string) *Query
- func (q *Query) LikeRight(col string, val string) *Query
- func (q *Query) LikeRightIf(cond bool, col string, val string) *Query
- func (q *Query) Limit(n int) *Query
- func (q *Query) Lt(col string, args ...any) *Query
- func (q *Query) LtIf(cond bool, col string, args ...any) *Query
- func (q *Query) Ne(col string, args ...any) *Query
- func (q *Query) NeIf(cond bool, col string, args ...any) *Query
- func (q *Query) NotIn(col string, args ...any) *Query
- func (q *Query) Offset(n int) *Query
- func (q *Query) Omit(col ...string) *Query
- func (q *Query) Or(query string, args ...any) *Query
- func (q *Query) OrFunc(f func(*Query) *Query) *Query
- func (q *Query) OrIf(cond bool, query string, args ...any) *Query
- func (q *Query) Order(order string) *Query
- func (q *Query) OrderAsc(col string) *Query
- func (q *Query) OrderDesc(col string) *Query
- func (q *Query) Raw(sql string, args ...any) *Query
- func (q *Query) Scan(ptr any) (rowsAffected int64, err error)
- func (q *Query) ScanAny(ptr any) (ok bool, err error)
- func (q *Query) ScanVal(ptr any) (err error)
- func (q *Query) Select(cols string, args ...any) *Query
- func (q *Query) SelectCols(v any) *Query
- func (q *Query) Set(col string, arg any) *Query
- func (q *Query) SetCols(arg any, cols ...string) *Query
- func (q *Query) SetColsIgnoreEmpty(arg any, cols ...string) *Query
- func (q *Query) SetIf(cond bool, col string, arg any) *Query
- func (q *Query) Table(table string) *Query
- func (q *Query) Update() (rowsAffected int64, err error)
- func (q *Query) UpdateAny() error
- func (q *Query) Where(query string, args ...any) *Query
- func (q *Query) WhereFunc(f func(*Query) *Query) *Query
- func (q *Query) WhereIf(addWhere bool, query string, args ...any) *Query
- func (q *Query) WhereNotNil(query string, v any) *Query
Constants ¶
View Source
const (
ErrCodeRecordNotFound = "RECORD_NOT_FOUND"
)
Variables ¶
View Source
var (
ErrRecordNotFound = errs.NewErrfCode(ErrCodeRecordNotFound, "Record Not Found")
)
Functions ¶
func ImplGetPrimaryDBFunc ¶ added in v0.1.18
func InitSchema ¶
func InitSchemaConditionally ¶ added in v0.1.17
func IterateAllByOffset ¶ added in v0.2.6
func NewGormLogger ¶ added in v0.2.0
func NewQueryFunc ¶ added in v0.2.0
Types ¶
type ChainedPageQuery ¶
type ConditionalSchemaSegment ¶ added in v0.1.17
type IterateByOffsetParam ¶ added in v0.2.6
type IteratePageParam ¶ added in v0.1.22
type IteratePageParam struct {
Limit int `json:"limit" desc:"page limit"`
}
type MisoJSONSerializer ¶ added in v0.2.10
type MisoJSONSerializer struct {
}
MisoJSONSerializer json serializer
type NilableValue ¶
type NilableValue struct {
// contains filtered or unexported fields
}
func (*NilableValue) IsZero ¶
func (n *NilableValue) IsZero() bool
func (*NilableValue) MarkZero ¶
func (n *NilableValue) MarkZero(isZero bool)
type PageQuery ¶
type PageQuery[V any] struct { // contains filtered or unexported fields }
Create param for page query.
func (*PageQuery[V]) IterateAll ¶ added in v0.1.22
func (*PageQuery[V]) IterateAllPages ¶ added in v0.2.12
func (*PageQuery[V]) TransformAsync ¶
func (pq *PageQuery[V]) TransformAsync(t util.TransformAsync[V]) *PageQuery[V]
func (*PageQuery[V]) WithBaseQuery ¶
func (pq *PageQuery[V]) WithBaseQuery(qry ChainedPageQuery) *PageQuery[V]
func (*PageQuery[V]) WithSelectQuery ¶
func (pq *PageQuery[V]) WithSelectQuery(qry ChainedPageQuery) *PageQuery[V]
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
func NewQuery ¶
Create New *Query.
opts can be *gorm.DB, miso.Rail or context.Context.
If *gorm.DB is missing, GetDB is called to obtain the primary one.
func (*Query) ColumnName ¶ added in v0.2.0
func (*Query) CreateIgnore ¶ added in v0.2.0
func (*Query) CreateIgnoreAny ¶ added in v0.2.15
func (*Query) LikeLeftIf ¶
LIKE '%?'
func (*Query) LikeRightIf ¶
LIKE '?%'
func (*Query) SelectCols ¶ added in v0.2.0
func (*Query) SetColsIgnoreEmpty ¶ added in v0.2.12
Click to show internal directories.
Click to hide internal directories.