dbquery

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSchema

func InitSchema(rail miso.Rail, initSchemaSegments []string, getDB func() *gorm.DB) error

func InitSchemaConditionally added in v0.1.17

func InitSchemaConditionally(rail miso.Rail, conditionalSegments []ConditionalSchemaSegment, getDB func() *gorm.DB) error

Types

type ChainedPageQuery

type ChainedPageQuery func(q *Query) *Query

type ConditionalSchemaSegment added in v0.1.17

type ConditionalSchemaSegment struct {
	Script    string
	Condition func(*gorm.DB) (ok bool, err error) // considered true if Condition is nil
	AfterExec func(*gorm.DB) error                // can be nil, called when script is executed without error
}

type Nilable

type Nilable interface {
	IsZero() bool
	MarkZero(isZero bool)
}

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 NewPagedQuery

func NewPagedQuery[V any](db *gorm.DB) *PageQuery[V]

func (*PageQuery[V]) Scan

func (pq *PageQuery[V]) Scan(rail miso.Rail, reqPage miso.Paging) (miso.PageRes[V], error)

func (*PageQuery[V]) Transform

func (pq *PageQuery[V]) Transform(t util.Transform[V]) *PageQuery[V]

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

func NewQuery(db *gorm.DB) *Query

func (*Query) And

func (q *Query) And(f func(*Query) *Query) *Query

func (*Query) Between

func (q *Query) Between(col string, args ...any) *Query

func (*Query) CopyNew

func (q *Query) CopyNew() *Query

func (*Query) Create

func (q *Query) Create(v any) (rowsAffected int64, err error)

func (*Query) DB

func (q *Query) DB() *gorm.DB

func (*Query) Eq

func (q *Query) Eq(col string, args ...any) *Query

=

func (*Query) EqIf

func (q *Query) EqIf(cond bool, col string, args ...any) *Query

=

func (*Query) Exec

func (q *Query) Exec(sql string, args ...any) (rowsAffected int64, err error)

func (*Query) From

func (q *Query) From(table string) *Query

Same as *Query.Table().

It was a mistake to call it From(), since we also use *Query to update tables :(

func (*Query) Ge

func (q *Query) Ge(col string, args ...any) *Query

>=

func (*Query) GeIf

func (q *Query) GeIf(cond bool, col string, args ...any) *Query

>=

func (*Query) Group

func (q *Query) Group(name string) *Query

func (*Query) Gt

func (q *Query) Gt(col string, args ...any) *Query

>

func (*Query) GtIf

func (q *Query) GtIf(cond bool, col string, args ...any) *Query

>

func (*Query) If

func (q *Query) If(cond bool, f func(*Query) *Query) *Query

func (*Query) IsNotNull

func (q *Query) IsNotNull(col string) *Query

func (*Query) IsNull

func (q *Query) IsNull(col string) *Query

func (*Query) Join

func (q *Query) Join(query string, args ...any) *Query

func (*Query) JoinIf

func (q *Query) JoinIf(addJoin bool, query string, args ...any) *Query

func (*Query) Le

func (q *Query) Le(col string, args ...any) *Query

<=

func (*Query) LeIf

func (q *Query) LeIf(cond bool, col string, args ...any) *Query

<=

func (*Query) Like

func (q *Query) Like(col string, val string) *Query

LIKE '%?%'

func (*Query) LikeIf

func (q *Query) LikeIf(cond bool, col string, val string) *Query

LIKE '%?%'

func (*Query) LikeLeft

func (q *Query) LikeLeft(col string, val string) *Query

LIKE '%?'

func (*Query) LikeLeftIf

func (q *Query) LikeLeftIf(cond bool, col string, val string) *Query

LIKE '%?'

func (*Query) LikeRight

func (q *Query) LikeRight(col string, val string) *Query

LIKE '?%'

func (*Query) LikeRightIf

func (q *Query) LikeRightIf(cond bool, col string, val string) *Query

LIKE '?%'

func (*Query) Limit

func (q *Query) Limit(n int) *Query

func (*Query) Lt

func (q *Query) Lt(col string, args ...any) *Query

<

func (*Query) LtIf

func (q *Query) LtIf(cond bool, col string, args ...any) *Query

<

func (*Query) Ne

func (q *Query) Ne(col string, args ...any) *Query

!=

func (*Query) NeIf

func (q *Query) NeIf(cond bool, col string, args ...any) *Query

!=

func (*Query) Offset

func (q *Query) Offset(n int) *Query

func (*Query) Or

func (q *Query) Or(query string, args ...any) *Query

func (*Query) OrFunc

func (q *Query) OrFunc(f func(*Query) *Query) *Query

func (*Query) OrIf

func (q *Query) OrIf(cond bool, query string, args ...any) *Query

func (*Query) Order

func (q *Query) Order(order string) *Query

func (*Query) Raw

func (q *Query) Raw(sql string, args ...any) *Query

func (*Query) Scan

func (q *Query) Scan(ptr any) (rowsAffected int64, err error)

func (*Query) Select

func (q *Query) Select(cols string, args ...any) *Query

func (*Query) Set

func (q *Query) Set(col string, arg any) *Query

func (*Query) SetIf

func (q *Query) SetIf(cond bool, col string, arg any) *Query

func (*Query) Table

func (q *Query) Table(table string) *Query

func (*Query) Update

func (q *Query) Update() (rowsAffected int64, err error)

func (*Query) Where

func (q *Query) Where(query string, args ...any) *Query

func (*Query) WhereFunc

func (q *Query) WhereFunc(f func(*Query) *Query) *Query

func (*Query) WhereIf

func (q *Query) WhereIf(addWhere bool, query string, args ...any) *Query

Jump to

Keyboard shortcuts

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