condition

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete added in v0.12.0

func Delete(builder sqlbuilder.DeleteBuilder, conditions ...Condition) sqlbuilder.DeleteBuilder

func Select added in v0.12.0

func Select(sb sqlbuilder.SelectBuilder, conditions ...Condition) sqlbuilder.SelectBuilder

func Update added in v0.12.0

func Update(builder sqlbuilder.UpdateBuilder, conditions ...Condition) sqlbuilder.UpdateBuilder

func WithOrValuesFunc added in v0.12.1

func WithOrValuesFunc(valueFunc func() []any) opts.Opt[ChainOperatorOpts]

func WithSkip added in v0.10.0

func WithSkip(skip bool) opts.Opt[ChainOperatorOpts]

func WithSkipFunc added in v0.10.0

func WithSkipFunc(skipFunc func() bool) opts.Opt[ChainOperatorOpts]

func WithValueFunc added in v0.12.1

func WithValueFunc(valueFunc func() any) opts.Opt[ChainOperatorOpts]

Types

type Chain added in v0.8.0

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

func NewChain added in v0.8.0

func NewChain() Chain

func NewChainWithConditions added in v0.8.0

func NewChainWithConditions(conditions ...Condition) Chain

func (Chain) Between added in v0.8.0

func (c Chain) Between(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) Build added in v0.11.0

func (c Chain) Build() []Condition

func (Chain) Equal added in v0.8.0

func (c Chain) Equal(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) GreaterEqualThan added in v0.8.0

func (c Chain) GreaterEqualThan(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) GreaterThan added in v0.8.0

func (c Chain) GreaterThan(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) In added in v0.8.0

func (c Chain) In(field string, values any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) LessEqualThan added in v0.8.0

func (c Chain) LessEqualThan(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) LessThan added in v0.8.0

func (c Chain) LessThan(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) Like added in v0.8.0

func (c Chain) Like(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) Limit added in v0.8.0

func (c Chain) Limit(value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) NotEqual added in v0.8.0

func (c Chain) NotEqual(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) NotIn added in v0.8.0

func (c Chain) NotIn(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) NotLike added in v0.8.0

func (c Chain) NotLike(field string, value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) Offset added in v0.8.0

func (c Chain) Offset(value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) Or added in v0.8.0

func (c Chain) Or(fields []string, operators []Operator, values []any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) OrderBy added in v0.8.0

func (c Chain) OrderBy(value any, op ...opts.Opt[ChainOperatorOpts]) Chain

func (Chain) Page added in v0.8.0

func (c Chain) Page(page, pageSize int, op ...opts.Opt[ChainOperatorOpts]) Chain

type ChainOperatorOpts added in v0.10.0

type ChainOperatorOpts struct {
	Skip     bool
	SkipFunc func() bool

	ValueFunc func() any

	OrValuesFunc func() []any
}

func (ChainOperatorOpts) DefaultOptions added in v0.10.0

func (opts ChainOperatorOpts) DefaultOptions() ChainOperatorOpts

type Condition

type Condition struct {
	Skip     bool
	SkipFunc func() bool

	// or condition
	Or bool

	OrOperators  []Operator
	OrFields     []string
	OrValues     []any
	OrValuesFunc func() []any

	// and condition
	Field string

	Operator  Operator
	Value     any
	ValueFunc func() any
}

func New

func New(conditions ...Condition) []Condition

type Operator added in v0.4.0

type Operator string
const (
	Equal            Operator = "="
	NotEqual         Operator = "!="
	GreaterThan      Operator = ">"
	LessThan         Operator = "<"
	GreaterEqualThan Operator = ">="
	LessEqualThan    Operator = "<="
	In               Operator = "IN"
	NotIn            Operator = "NOT IN"
	Like             Operator = "LIKE"
	NotLike          Operator = "NOT LIKE"
	Limit            Operator = "LIMIT"
	Offset           Operator = "OFFSET"
	Between          Operator = "BETWEEN"
	NotBetween       Operator = "NOT BETWEEN"
	OrderBy          Operator = "ORDER BY"
)

func (Operator) String added in v0.4.0

func (o Operator) String() string

Jump to

Keyboard shortcuts

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