condition

package
v0.60.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdaptField added in v0.40.0

func AdaptField(field string) string

func AdaptTable added in v0.40.0

func AdaptTable(table string) string

func Delete

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

func RawFieldNames

func RawFieldNames(in any) []string

RawFieldNames converts golang struct field into slice string.

func RemoveIgnoreColumns

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

func Select

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

func SelectByWhereRawSql

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

func ToSlice

func ToSlice(i any) []any

func Unquote

func Unquote(s string) string

func Update

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

func WithOrValuesFunc

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

func WithSkip

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

func WithSkipFunc

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

func WithValueFunc

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

Types

type Chain

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

func NewChain

func NewChain(conditions ...Condition) Chain

func NewChainWithConditions deprecated

func NewChainWithConditions(conditions ...Condition) Chain

Deprecated: Use NewChain instead

func (Chain) AddCondition

func (c Chain) AddCondition(condition Condition) Chain

func (Chain) Between

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

func (Chain) Build

func (c Chain) Build() []Condition

func (Chain) Equal

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

func (Chain) GreaterEqualThan

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

func (Chain) GreaterThan

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

func (Chain) GroupBy

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

func (Chain) In

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

func (Chain) Join

func (c Chain) Join(option sqlbuilder.JoinOption, table string, onExpr ...string) Chain

func (Chain) LessEqualThan

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

func (Chain) LessThan

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

func (Chain) Like

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

func (Chain) Limit

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

func (Chain) NotEqual

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

func (Chain) NotIn

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

func (Chain) NotLike

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

func (Chain) Offset

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

func (Chain) Or

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

func (Chain) OrderBy

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

func (Chain) Page

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

func (Chain) WhereClause

func (c Chain) WhereClause(whereClause *sqlbuilder.WhereClause) Chain

type ChainOperatorOpts

type ChainOperatorOpts struct {
	Skip     bool
	SkipFunc func() bool

	ValueFunc func() any

	OrValuesFunc func() []any
}

func (ChainOperatorOpts) DefaultOptions

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     []Field
	OrValues     []any
	OrValuesFunc func() []any

	// Field for default and condition
	Field Field

	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 Field

type Field string

func (Field) String added in v0.40.0

func (f Field) String() string

type JoinCondition

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

type Operator

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

func (o Operator) String() string

Jump to

Keyboard shortcuts

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