Query

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	OperatorIn                 Operator = "IN"
	OperatorNotIn              Operator = "NOT IN"
	OperatorLike               Operator = "LIKE"
	OperatorNotLike            Operator = "NOT LIKE"
	OperatorEqual              Operator = "="
	OperatorGreaterThan        Operator = ">"
	OperatorLessThan           Operator = "<"
	OperatorGreaterThanOrEqual Operator = ">="
	OperatorLessThanOrEqual    Operator = "<="
	OperatorNotEqual           Operator = "<>"
	OperatorJSONBContains      Operator = "@>"

	ConnectorAND Connector = " AND "
	ConnectorOR  Connector = " OR "
)
View Source
const DefaultPaginationLimit = 100

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	IDB            bun.IDB
	Model          any
	Pagination     *Pagination
	DefaultOrderBy []OrderBy
	Filterables    []Filterable
	Columns        []string
	Relations      []string
}

func (*Config) Validate

func (c *Config) Validate() error

type Connector

type Connector string

type Filter

type Filter struct {
	Column   string
	Operator Operator
	Value    any
}

func (*Filter) ApplyTo

func (f *Filter) ApplyTo(q *bun.SelectQuery) *bun.SelectQuery

func (*Filter) Validate

func (f *Filter) Validate() error

type FilterGroup

type FilterGroup struct {
	Filters   []Filter
	Connector Connector
}

func (*FilterGroup) ApplyTo

func (f *FilterGroup) ApplyTo(q *bun.SelectQuery) *bun.SelectQuery

type Filterable

type Filterable interface {
	ApplyTo(q *bun.SelectQuery) *bun.SelectQuery
}

Filterable is an interface for types that can be applied to a Bun query

type Operator

type Operator string

type OrderBy

type OrderBy struct {
	Column    string         `json:"column"`
	Direction OrderDirection `json:"direction"`
}

func (*OrderBy) String

func (ob *OrderBy) String() string

func (*OrderBy) Validate

func (ob *OrderBy) Validate() error

type OrderDirection

type OrderDirection string
const (
	OrderAscending  OrderDirection = "ASC"
	OrderDescending OrderDirection = "DESC"
)

type Pagination

type Pagination struct {
	Offset int `json:"offset"`
	Limit  int `json:"limit"`
	Total  int `json:"total"`
}

func DefaultPagination

func DefaultPagination() *Pagination

DefaultPagination returns a Pagination with offset 0 and the default limit.

func (*Pagination) Validate

func (p *Pagination) Validate() error

type Query

type Query struct {
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, conf *Config) (*Query, error)

func (*Query) Scan

func (q *Query) Scan(ctx context.Context) error

func (*Query) TotalCount

func (q *Query) TotalCount() int

type StringQueryInfo

type StringQueryInfo struct {
	Patterns   []string
	IsWildcard bool
	UseOR      bool
}

func (*StringQueryInfo) ToFilterable

func (info *StringQueryInfo) ToFilterable(col string) Filterable

Jump to

Keyboard shortcuts

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