Documentation
¶
Overview ¶
Package query is a Knex-style fluent query builder for tables without a model. Builders are mutable: every method modifies and returns the same *Builder.
Index ¶
- type Builder
- func (b *Builder) Count(ctx context.Context) (int64, error)
- func (b *Builder) Delete(ctx context.Context) (int64, error)
- func (b *Builder) First(ctx context.Context) (Row, error)
- func (b *Builder) Get(ctx context.Context) ([]Row, error)
- func (b *Builder) GroupBy(cols ...string) *Builder
- func (b *Builder) Having(query any, args ...any) *Builder
- func (b *Builder) Insert(ctx context.Context, rows ...Row) error
- func (b *Builder) Join(clause string, args ...any) *Builder
- func (b *Builder) Limit(n int) *Builder
- func (b *Builder) Not(query any, args ...any) *Builder
- func (b *Builder) Offset(n int) *Builder
- func (b *Builder) OrWhere(query any, args ...any) *Builder
- func (b *Builder) OrderBy(col, dir string) *Builder
- func (b *Builder) Paginate(ctx context.Context, page, perPage int) (Page, error)
- func (b *Builder) Pluck(ctx context.Context, col string) ([]any, error)
- func (b *Builder) Select(cols ...string) *Builder
- func (b *Builder) String() string
- func (b *Builder) Update(ctx context.Context, values Row) (int64, error)
- func (b *Builder) Where(query any, args ...any) *Builder
- func (b *Builder) WhereBetween(col string, lo, hi any) *Builder
- func (b *Builder) WhereIn(col string, values any) *Builder
- func (b *Builder) WhereNotNull(col string) *Builder
- func (b *Builder) WhereNull(col string) *Builder
- type Page
- type Row
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) Delete ¶
Delete removes matching rows. Without a Where, GORM refuses and an error is returned.
func (*Builder) OrderBy ¶
OrderBy sorts by col; dir is "asc" or "desc" (anything else is rejected at execution).
func (*Builder) Update ¶
Update sets columns on matching rows and returns the affected count. Without a Where, GORM refuses and an error is returned.
func (*Builder) Where ¶
Where accepts a SQL fragment with ? placeholders ("age > ?", 18) or a map[string]any. Values are always bound, never interpolated.
func (*Builder) WhereNotNull ¶
Click to show internal directories.
Click to hide internal directories.