condition

package
v0.25.2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: MIT Imports: 8 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 Field added in v0.25.0

func Field(field string) string

func RawFieldNames added in v0.25.0

func RawFieldNames(in any) []string

RawFieldNames converts golang struct field into slice string.

func RemoveIgnoreColumns added in v0.25.0

func RemoveIgnoreColumns(strings []string, strs ...string) []string

func Select added in v0.12.0

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

func SelectByWhereRawSql added in v0.19.3

func SelectByWhereRawSql(sb *sqlbuilder.SelectBuilder, originalField string, args ...any)

func Table added in v0.25.0

func Table(table string) string

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(conditions ...Condition) Chain

func NewChainWithConditions deprecated added in v0.8.0

func NewChainWithConditions(conditions ...Condition) Chain

Deprecated: Use NewChain instead

func (Chain) AddCondition added in v0.20.0

func (c Chain) AddCondition(condition 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) GroupBy added in v0.15.0

func (c Chain) GroupBy(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) Join added in v0.19.3

func (c Chain) Join(option sqlbuilder.JoinOption, table string, onExpr ...string) 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

func (Chain) WhereClause added in v0.20.0

func (c Chain) WhereClause(whereClause *sqlbuilder.WhereClause) 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 indicates whether the condition is effective.
	Skip bool

	// SkipFunc The priority is higher than Skip.
	SkipFunc func() bool

	// Or indicates an or condition
	Or bool

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

	// Field for default and condition
	Field string

	Operator Operator
	Value    any

	// ValueFunc The priority is higher than Value.
	ValueFunc func() any

	// JoinCondition
	JoinCondition

	WhereClause *sqlbuilder.WhereClause
}

func New

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

type JoinCondition added in v0.19.3

type JoinCondition struct {
	Option sqlbuilder.JoinOption
	Table  string
	OnExpr []string
}

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"
	GroupBy          Operator = "GROUP BY"
	Join             Operator = "JOIN"
)

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