c

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2020 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package c defines function for building condition in query.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	Type  ConditionType
	Left  Operand
	Right Operand
	Inner []Condition
}

Condition defines details of a coundition type.

func And

func And(inner ...Condition) Condition

And compares other conditions using and.

func Eq

func Eq(left, right interface{}) Condition

Eq compares that left value is equal to right value.

func Fragment

func Fragment(expr I, values ...interface{}) Condition

Fragment add custom condition.

func Gt

func Gt(left, right interface{}) Condition

Gt compares that left value is greater than to right value.

func Gte

func Gte(left, right interface{}) Condition

Gte compares that left value is greater than or equal to right value.

func In

func In(col I, values ...interface{}) Condition

In check whethers value of the column is included in values.

func Like

func Like(col I, pattern string) Condition

Like compares value of column to match string pattern.

func Lt

func Lt(left, right interface{}) Condition

Lt compares that left value is less than to right value.

func Lte

func Lte(left, right interface{}) Condition

Lte compares that left value is less than or equal to right value.

func Ne

func Ne(left, right interface{}) Condition

Ne compares that left value is not equal to right value.

func Nil

func Nil(col I) Condition

Nil check whether column is nil.

func Nin

func Nin(col I, values ...interface{}) Condition

Nin check whethers value of the column is not included in values.

func Not

func Not(inner ...Condition) Condition

Not wraps conditions using not. It'll negate the condition type if possible.

func NotLike

func NotLike(col I, pattern string) Condition

NotLike compares value of column to not match string pattern.

func NotNil

func NotNil(col I) Condition

NotNil check whether column is not nil.

func Or

func Or(inner ...Condition) Condition

Or compares other conditions using and.

func (Condition) And

func (c Condition) And(condition ...Condition) Condition

And wraps conditions using and.

func (Condition) None

func (c Condition) None() bool

None returns true if no condition is specified.

func (Condition) Or

func (c Condition) Or(condition ...Condition) Condition

Or wraps conditions using or.

type ConditionType

type ConditionType int

ConditionType defines enumeration of all supported condition types.

const (
	// ConditionAnd is condition type for and operator.
	ConditionAnd ConditionType = iota
	// ConditionOr is condition type for or operator.
	ConditionOr
	// ConditionNot is condition type for not operator.
	ConditionNot

	// ConditionEq is condition type for equal comparison.
	ConditionEq
	// ConditionNe is condition type for not equal comparison.
	ConditionNe

	// ConditionLt is condition type for less than comparison.
	ConditionLt
	// ConditionLte is condition type for less than or equal comparison.
	ConditionLte
	// ConditionGt is condition type for greater than comparison.
	ConditionGt
	// ConditionGte is condition type for greter than or equal comparison.
	ConditionGte

	// ConditionNil is condition type for nil check.
	ConditionNil
	// ConditionNotNil is condition type for not nil check.
	ConditionNotNil

	// ConditionIn is condition type for inclusion comparison.
	ConditionIn
	// ConditionNin is condition type for not inclusion comparison.
	ConditionNin

	// ConditionLike is condition type for like comparison.
	ConditionLike
	// ConditionNotLike is condition type for not like comparison.
	ConditionNotLike

	// ConditionFragment is condition type for custom condition.
	ConditionFragment
)

type I

type I string

I identifies database variable such as column name or table name.

type Join

type Join struct {
	Mode       string
	Collection string
	Condition  Condition
}

Join defines join information in query.

type Operand

type Operand struct {
	Column I
	Values []interface{}
}

Operand defines information about condition's operand.

func NewOperand

func NewOperand(o ...interface{}) Operand

NewOperand create new operand.

type Order

type Order struct {
	Field I
	Order int
}

Order defines order information of query.

func Asc

func Asc(field I) Order

Asc orders field with ascending order.

func Desc

func Desc(field I) Order

Desc orders field with descending order.

func (Order) Asc

func (order Order) Asc() bool

Asc returns true if order is ascending.

func (Order) Desc

func (order Order) Desc() bool

Desc returns true if order is descending.

Jump to

Keyboard shortcuts

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