field

package
v0.0.0-...-1797280 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package field implement all type field and method

Index

Constants

View Source
const (
	TagKeyGorm = "gorm"
	TagKeyJson = "json"

	//gorm tag
	TagKeyGormColumn        = "column"
	TagKeyGormType          = "type"
	TagKeyGormPrimaryKey    = "primaryKey"
	TagKeyGormAutoIncrement = "autoIncrement"
	TagKeyGormNotNull       = "not null"
	TagKeyGormUniqueIndex   = "uniqueIndex"
	TagKeyGormIndex         = "index"
	TagKeyGormDefault       = "default"
	TagKeyGormComment       = "comment"
)

Variables

View Source
var (
	// Star a symbol of "*"
	Star = NewAsterisk("")
	// ALL same with Star
	ALL = Star
)
View Source
var Func = new(function)

Func sql functions

View Source
var (
	// RelationFieldUnscoped relation fild unscoped
	RelationFieldUnscoped relationScope = func(tx *gorm.DB) *gorm.DB {
		return tx.Unscoped()
	}
)

Functions

func Attrs

func Attrs(attr interface{}) *attrs

Types

type AssignExpr

type AssignExpr interface {
	Expr

	AssignExpr() expression
}

AssignExpr assign expression

func AssignSubQuery

func AssignSubQuery(columns []Expr, subQuery *gorm.DB) AssignExpr

AssignSubQuery assign with subquery

type Asterisk

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

Asterisk a type of xxx.*

func NewAsterisk

func NewAsterisk(table string, opts ...Option) Asterisk

NewAsterisk create new * field

func (Asterisk) BuildWithArgs

func (e Asterisk) BuildWithArgs(*gorm.Statement) (query sql, args []interface{})

func (Asterisk) Count

func (a Asterisk) Count() Asterisk

Count count

func (Asterisk) Distinct

func (a Asterisk) Distinct() Asterisk

Distinct distinct

type Bool

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

Bool boolean type field

func NewBool

func NewBool(table, column string, opts ...Option) Bool

NewBool ...

func (Bool) And

func (field Bool) And(value bool) Expr

And boolean and

func (Bool) BitAnd

func (field Bool) BitAnd(value bool) Expr

BitAnd ...

func (Bool) BitOr

func (field Bool) BitOr(value bool) Expr

BitOr ...

func (Bool) BitXor

func (field Bool) BitXor(value bool) Expr

BitXor ...

func (Bool) Eq

func (field Bool) Eq(value T) Expr

Eq judge equal

func (Bool) Field

func (field Bool) Field(value []interface{}) Expr

Field ...

func (Bool) Gt

func (field Bool) Gt(value T) Expr

Gt ...

func (Bool) Gte

func (field Bool) Gte(value T) Expr

Gte ...

func (Bool) IfNull

func (field Bool) IfNull(value T) Expr

IfNull ...

func (Bool) In

func (field Bool) In(values ...T) Expr

In ...

func (Bool) Is

func (field Bool) Is(value bool) Expr

Is ...

func (Bool) Like

func (field Bool) Like(value string) Expr

Like ...

func (Bool) Lt

func (field Bool) Lt(value T) Expr

Lt ...

func (Bool) Lte

func (field Bool) Lte(value T) Expr

Lte ...

func (Bool) Neq

func (field Bool) Neq(value T) Expr

Neq judge not equal

func (Bool) Not

func (field Bool) Not() Bool

Not ...

func (Bool) NotIn

func (field Bool) NotIn(values ...T) Expr

NotIn ...

func (Bool) NotLike

func (field Bool) NotLike(value string) Expr

NotLike ...

func (Bool) Or

func (field Bool) Or(value bool) Expr

Or boolean or

func (Bool) Sum

func (field Bool) Sum() genericsField[T]

Sum ...

func (Bool) Value

func (field Bool) Value(value T) AssignExpr

Value ...

func (Bool) Xor

func (field Bool) Xor(value bool) Expr

Xor ...

func (Bool) Zero

func (field Bool) Zero() AssignExpr

Zero ...

type BuildOpt

type BuildOpt uint

BuildOpt build option

const (
	// WithTable build column with table
	WithTable BuildOpt = iota

	// WithAll build column with table and alias
	WithAll

	// WithoutQuote build column without quote
	WithoutQuote
)

type Bytes

type Bytes = Chars[[]byte]

Bytes []byte type field

func NewBytes

func NewBytes(table, column string, opts ...Option) Bytes

NewBytes ...

type Chars

type Chars[T ~string | ~[]byte] struct {
	// contains filtered or unexported fields
}

Chars string type field

func (Chars[T]) Between

func (field Chars[T]) Between(left T, right T) Expr

Between ...

func (Chars[T]) Concat

func (field Chars[T]) Concat(before, after string) Chars[T]

Concat ...

func (Chars) Eq

func (field Chars) Eq(value T) Expr

Eq judge equal

func (Chars[T]) Field

func (field Chars[T]) Field(values ...T) Chars[T]

Field ...

func (Chars[T]) FindInSet

func (field Chars[T]) FindInSet(targetList string) Expr

FindInSet equal to FIND_IN_SET(field_name, input_string_list)

func (Chars[T]) FindInSetWith

func (field Chars[T]) FindInSetWith(target string) Expr

FindInSetWith equal to FIND_IN_SET(input_string, field_name)

func (Chars) Gt

func (field Chars) Gt(value T) Expr

Gt ...

func (Chars) Gte

func (field Chars) Gte(value T) Expr

Gte ...

func (Chars) IfNull

func (field Chars) IfNull(value T) Expr

IfNull ...

func (Chars) In

func (field Chars) In(values ...T) Expr

In ...

func (Chars) Like

func (field Chars) Like(value string) Expr

Like ...

func (Chars[T]) Lower

func (field Chars[T]) Lower() Chars[T]

Lower converts a string to lower-case.

func (Chars) Lt

func (field Chars) Lt(value T) Expr

Lt ...

func (Chars) Lte

func (field Chars) Lte(value T) Expr

Lte ...

func (Chars) Neq

func (field Chars) Neq(value T) Expr

Neq judge not equal

func (Chars[T]) NotBetween

func (field Chars[T]) NotBetween(left T, right T) Expr

NotBetween ...

func (Chars[T]) NotIn

func (field Chars[T]) NotIn(values ...T) Expr

NotIn ...

func (Chars) NotLike

func (field Chars) NotLike(value string) Expr

NotLike ...

func (Chars[T]) NotRegexp

func (field Chars[T]) NotRegexp(value string) Expr

NotRegexp ...

func (Chars[T]) Regexp

func (field Chars[T]) Regexp(value string) Expr

Regexp ...

func (Chars[T]) Replace

func (field Chars[T]) Replace(from, to string) Chars[T]

Replace ...

func (Chars[T]) Substr

func (field Chars[T]) Substr(params ...int) Chars[T]

Substr SUBSTR is a synonym for SUBSTRING https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_substring

func (Chars[T]) Substring

func (field Chars[T]) Substring(params ...int) Chars[T]

Substring https://dev.mysql.com/doc/refman/8.4/en/string-functions.html#function_substring

func (Chars[T]) SubstringIndex

func (field Chars[T]) SubstringIndex(delim string, count int) Chars[T]

SubstringIndex SUBSTRING_INDEX https://dev.mysql.com/doc/refman/8.0/en/functions.html#function_substring-index

func (Chars) Sum

func (field Chars) Sum() genericsField[T]

Sum ...

func (Chars[T]) Upper

func (field Chars[T]) Upper() Chars[T]

Upper converts a string to upper-case.

func (Chars) Value

func (field Chars) Value(value T) AssignExpr

Value ...

func (Chars[T]) Zero

func (field Chars[T]) Zero() AssignExpr

Zero ...

type CompareOperator

type CompareOperator string

CompareOperator compare operator

const (
	// EqOp =
	EqOp CompareOperator = " = "
	// NeqOp <>
	NeqOp CompareOperator = " <> "
	// GtOp >
	GtOp CompareOperator = " > "
	// GteOp >=
	GteOp CompareOperator = " >= "
	// LtOp <
	LtOp CompareOperator = " < "
	// LteOp <=
	LteOp CompareOperator = " <= "
	// ExistsOp EXISTS
	ExistsOp CompareOperator = "EXISTS "
)

type Expr

type Expr interface {
	// Clause Expression interface
	Build(clause.Builder)

	As(alias string) Expr
	IColumnName
	BuildColumn(*gorm.Statement, ...BuildOpt) sql
	BuildWithArgs(*gorm.Statement) (query sql, args []interface{})
	RawExpr() expression

	// col operate expression
	AddCol(col Expr) Expr
	SubCol(col Expr) Expr
	MulCol(col Expr) Expr
	DivCol(col Expr) Expr
	ConcatCol(cols ...Expr) Expr

	// implement Condition
	BeCond() interface{}
	CondError() error
	// contains filtered or unexported methods
}

Expr a query expression about field

var AssociationFields Expr = NewString("", clause.Associations).appendBuildOpts(WithoutQuote)

AssociationFields all association

func And

func And(exprs ...Expr) Expr

And return and condition

func CompareSubQuery

func CompareSubQuery(op CompareOperator, column Expr, subQuery *gorm.DB) Expr

CompareSubQuery compare with sub query

func ContainsSubQuery

func ContainsSubQuery(columns []Expr, subQuery *gorm.DB) Expr

ContainsSubQuery return contains subquery when len(columns) == 1, equal to columns[0] IN (subquery) when len(columns) > 1, equal to (columns[0], columns[1], ...) IN (subquery)

func ContainsValue

func ContainsValue(columns []Expr, value Value) Expr

ContainsValue return expression which compare with value

func EmptyExpr

func EmptyExpr() Expr

EmptyExpr return a empty expression

func Not

func Not(exprs ...Expr) Expr

Not return not condition

func Or

func Or(exprs ...Expr) Expr

Or return or condition

type Field

type Field = genericsField[driver.Valuer]

Field a standard field struct

func NewField

func NewField(table, column string, opts ...Option) Field

NewField create new field

func NewUnsafeFieldRaw

func NewUnsafeFieldRaw(rawSQL string, vars ...interface{}) Field

NewUnsafeFieldRaw create new field by native sql

Warning: Using NewUnsafeFieldRaw with raw SQL exposes your application to SQL injection vulnerabilities. Always validate/sanitize inputs and prefer parameterized queries or NewField methods for field construction. Use this low-level function only when absolutely necessary, and ensure any embedded values are properly escaped.

type Float32

type Float32 = Number[float32]

Float32 type field

func NewFloat32

func NewFloat32(table, column string, opts ...Option) Float32

NewFloat32 create new field for float32

type Float64

type Float64 = Number[float64]

Float64 type field

func NewFloat64

func NewFloat64(table, column string, opts ...Option) Float64

NewFloat64 create new field for float64

type GormTag

type GormTag map[string][]string

func (GormTag) Append

func (tag GormTag) Append(key string, values ...string) GormTag

func (GormTag) Build

func (tag GormTag) Build() string

func (GormTag) Remove

func (tag GormTag) Remove(key string) GormTag

func (GormTag) Set

func (tag GormTag) Set(key string, values ...string) GormTag

type IColumnName

type IColumnName interface {
	ColumnName() sql
}

type IValues

type IValues interface {
	Values() interface{}
}

type Int

type Int = Number[int]

Int type field

func NewInt

func NewInt(table, column string, opts ...Option) Int

NewInt create new field for int

type Int8

type Int8 = Number[int8]

Int8 type field

func NewInt8

func NewInt8(table, column string, opts ...Option) Int8

NewInt8 create new field for int8

type Int16

type Int16 = Number[int16]

Int16 type field

func NewInt16

func NewInt16(table, column string, opts ...Option) Int16

NewInt16 create new field for int16

type Int32

type Int32 = Number[int32]

Int32 type field

func NewInt32

func NewInt32(table, column string, opts ...Option) Int32

NewInt32 create new field for int32

type Int64

type Int64 = Number[int64]

Int64 type field

func NewInt64

func NewInt64(table, column string, opts ...Option) Int64

NewInt64 create new field for int64

type Number

type Number[T constraints.Integer | constraints.Float] struct {
	// contains filtered or unexported fields
}

Number int type field

func NewNumber

func NewNumber[T constraints.Integer | constraints.Float](table, column string, opts ...Option) Number[T]

NewNumber build number type field

func (Number[T]) Add

func (field Number[T]) Add(value T) Number[T]

Add ...

func (Number[T]) Between

func (field Number[T]) Between(left T, right T) Expr

Between ...

func (Number[T]) BitAnd

func (field Number[T]) BitAnd(value T) Number[T]

BitAnd ...

func (Number[T]) BitFlip

func (field Number[T]) BitFlip() Number[T]

BitFlip ...

func (Number[T]) BitOr

func (field Number[T]) BitOr(value T) Number[T]

BitOr ...

func (Number[T]) BitXor

func (field Number[T]) BitXor(value T) Number[T]

BitXor ...

func (Number[T]) Div

func (field Number[T]) Div(value T) Number[T]

Div ...

func (Number) Eq

func (field Number) Eq(value T) Expr

Eq judge equal

func (Number[T]) Field

func (field Number[T]) Field(values ...T) Number[T]

Field ...

func (Number[T]) Floor

func (field Number[T]) Floor() Number[T]

Floor ...

func (Number[T]) FloorDiv

func (field Number[T]) FloorDiv(value T) Number[T]

FloorDiv ...

func (Number) Gt

func (field Number) Gt(value T) Expr

Gt ...

func (Number) Gte

func (field Number) Gte(value T) Expr

Gte ...

func (Number) IfNull

func (field Number) IfNull(value T) Expr

IfNull ...

func (Number) In

func (field Number) In(values ...T) Expr

In ...

func (Number[T]) LeftShift

func (field Number[T]) LeftShift(value T) Number[T]

LeftShift ...

func (Number) Like

func (field Number) Like(value string) Expr

Like ...

func (Number) Lt

func (field Number) Lt(value T) Expr

Lt ...

func (Number) Lte

func (field Number) Lte(value T) Expr

Lte ...

func (Number[T]) Mod

func (field Number[T]) Mod(value T) Number[T]

Mod ...

func (Number[T]) Mul

func (field Number[T]) Mul(value T) Number[T]

Mul ...

func (Number) Neq

func (field Number) Neq(value T) Expr

Neq judge not equal

func (Number[T]) NotBetween

func (field Number[T]) NotBetween(left T, right T) Expr

NotBetween ...

func (Number[T]) NotIn

func (field Number[T]) NotIn(values ...T) Expr

NotIn ...

func (Number) NotLike

func (field Number) NotLike(value string) Expr

NotLike ...

func (Number[T]) RightShift

func (field Number[T]) RightShift(value T) Number[T]

RightShift ...

func (Number[T]) Sub

func (field Number[T]) Sub(value T) Number[T]

Sub ...

func (Number) Sum

func (field Number) Sum() genericsField[T]

Sum ...

func (Number) Value

func (field Number) Value(value T) AssignExpr

Value ...

func (Number[T]) Zero

func (field Number[T]) Zero() AssignExpr

Zero set zero value

type Option

type Option func(clause.Column) clause.Column

Option field option

type OrderExpr

type OrderExpr interface {
	Expr
	Desc() Expr
	Asc() Expr
}

OrderExpr order expression used in Order()

type RelateConfig

type RelateConfig struct {
	RelatePointer      bool
	RelateSlice        bool
	RelateSlicePointer bool

	JSONTag      string
	GORMTag      GormTag
	Tag          Tag
	OverwriteTag Tag
}

RelateConfig config for relationship

func (*RelateConfig) GetTag

func (c *RelateConfig) GetTag(fieldName string) Tag

func (*RelateConfig) RelateFieldPrefix

func (c *RelateConfig) RelateFieldPrefix(relationshipType RelationshipType) string

RelateFieldPrefix return generated relation field's type

type Relation

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

Relation relation meta info

func NewRelation

func NewRelation(fieldName string, fieldType string, relations ...Relation) *Relation

NewRelation return a new Relation for association

func NewRelationWithModel

func NewRelationWithModel(relationship RelationshipType, fieldName string, fieldType string, fieldModel interface{}, relations ...Relation) *Relation

NewRelationWithModel return a Relation with specified model struct

func NewRelationWithType

func NewRelationWithType(relationship RelationshipType, fieldName string, fieldType string, relations ...Relation) *Relation

NewRelationWithType return a Relation with specified field type

func (*Relation) AppendChildRelation

func (r *Relation) AppendChildRelation(relations ...Relation)

AppendChildRelation append child relationship

func (Relation) ChildRelations

func (r Relation) ChildRelations() []Relation

ChildRelations return child relations

func (Relation) Clauses

func (r Relation) Clauses(hints ...clause.Expression) RelationField

Clauses set relation clauses

func (Relation) Field

func (r Relation) Field(fields ...string) Expr

Field build field

func (*Relation) GetClauses

func (r *Relation) GetClauses() []clause.Expression

GetClauses get clauses

func (*Relation) GetConds

func (r *Relation) GetConds() []Expr

GetConds get query conditions

func (*Relation) GetJoins

func (r *Relation) GetJoins() []RelationJoin

GetJoins returns the joins for the relation

func (*Relation) GetOrderCol

func (r *Relation) GetOrderCol() []Expr

GetOrderCol get order columns

func (*Relation) GetPage

func (r *Relation) GetPage() (offset, limit int)

GetPage get offset and limit

func (*Relation) GetScopes

func (r *Relation) GetScopes() []relationScope

GetScopes get scope functions

func (*Relation) GetSelects

func (r *Relation) GetSelects() []Expr

GetSelects get select columns

func (Relation) Join

func (r Relation) Join(table schema.Tabler, conds ...Expr) RelationField

Join adds an INNER JOIN clause to the relation

func (Relation) LeftJoin

func (r Relation) LeftJoin(table schema.Tabler, conds ...Expr) RelationField

LeftJoin adds a LEFT JOIN clause to the relation

func (Relation) Limit

func (r Relation) Limit(limit int) RelationField

Limit set relation limit

func (Relation) Model

func (r Relation) Model() interface{}

Model relation field's model

func (Relation) Name

func (r Relation) Name() string

Name relation field' name

func (Relation) Offset

func (r Relation) Offset(offset int) RelationField

Offset set relation offset

func (Relation) On

func (r Relation) On(conds ...Expr) RelationField

On relation condition

func (Relation) Order

func (r Relation) Order(columns ...Expr) RelationField

Order relation order columns

func (Relation) Path

func (r Relation) Path() string

Path relation field's path

func (Relation) Relationship

func (r Relation) Relationship() RelationshipType

Relationship relationship between field and table struct

func (Relation) RelationshipName

func (r Relation) RelationshipName() string

RelationshipName relationship's name

func (Relation) RightJoin

func (r Relation) RightJoin(table schema.Tabler, conds ...Expr) RelationField

RightJoin adds a RIGHT JOIN clause to the relation

func (Relation) Scopes

func (r Relation) Scopes(funcs ...relationScope) RelationField

Scopes set scopes func

func (Relation) Select

func (r Relation) Select(columns ...Expr) RelationField

Select relation select columns

func (*Relation) StructField

func (r *Relation) StructField() (fieldStr string)

StructField return struct field code

func (*Relation) StructFieldInit

func (r *Relation) StructFieldInit() string

StructFieldInit return field initialize code

func (Relation) Type

func (r Relation) Type() string

Type relation field's type

type RelationField

type RelationField interface {
	Name() string
	Path() string
	// Field return expr for Select
	// Field() return "<self>" field name in struct
	// Field("RelateField") return "<self>.RelateField" for Select
	// Field("RelateField", "RelateRelateField") return "<self>.RelateField.RelateRelateField" for Select
	// ex:
	// 	Select(u.CreditCards.Field()) equals to GORM: Select("CreditCards")
	// 	Select(u.CreditCards.Field("Bank")) equals to GORM: Select("CreditCards.Bank")
	// 	Select(u.CreditCards.Field("Bank","Owner")) equals to GORM: Select("CreditCards.Bank.Owner")
	Field(fields ...string) Expr
	Join(table schema.Tabler, conds ...Expr) RelationField
	LeftJoin(table schema.Tabler, conds ...Expr) RelationField
	RightJoin(table schema.Tabler, conds ...Expr) RelationField
	On(conds ...Expr) RelationField
	Select(conds ...Expr) RelationField
	Order(columns ...Expr) RelationField
	Clauses(hints ...clause.Expression) RelationField
	Scopes(funcs ...relationScope) RelationField
	Offset(offset int) RelationField
	Limit(limit int) RelationField

	GetConds() []Expr
	GetSelects() []Expr
	GetOrderCol() []Expr
	GetClauses() []clause.Expression
	GetScopes() []relationScope
	GetPage() (offset, limit int)
	GetJoins() []RelationJoin
}

RelationField interface for relation field

var Associations RelationField = NewRelation(clause.Associations, "")

Associations ...

type RelationJoin

type RelationJoin struct {
	Table     schema.Tabler
	Type      clause.JoinType
	Condition []Expr
}

RelationJoin represents a join operation for a relation

type RelationshipType

type RelationshipType schema.RelationshipType

RelationshipType table relationship

const (
	// HasOne a has one association sets up a one-to-one connection with another model. Reference https://gorm.io/docs/has_one.html
	HasOne RelationshipType = RelationshipType(schema.HasOne) // HasOneRel has one relationship
	// HasMany a has many association sets up a one-to-many connection with another model. Reference https://gorm.io/docs/has_many.html
	HasMany RelationshipType = RelationshipType(schema.HasMany) // HasManyRel has many relationships
	// BelongsTo A belongs to association sets up a one-to-one connection with another model. Reference https://gorm.io/docs/belongs_to.html
	BelongsTo RelationshipType = RelationshipType(schema.BelongsTo) // BelongsToRel belongs to relationship
	// Many2Many Many to Many add a join table between two models. Reference https://gorm.io/docs/many2many.html
	Many2Many RelationshipType = RelationshipType(schema.Many2Many) // Many2ManyRel many to many relationship
)

type ScanValuer

type ScanValuer interface {
	Scan(src interface{}) error   // sql.Scanner
	Value() (driver.Value, error) // driver.Valuer
}

ScanValuer interface for Field

type Serializer

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

Serializer a standard field struct

func NewSerializer

func NewSerializer(table, column string, opts ...Option) Serializer

NewSerializer create new field2

func (Serializer) Abs

func (e Serializer) Abs() Number[float64]

func (Serializer) AddCol

func (e Serializer) AddCol(col Expr) Expr

======================== operate columns ========================

func (Serializer) As

func (e Serializer) As(alias string) Expr

======================== keyword ========================

func (Serializer) Asc

func (e Serializer) Asc() Expr

Asc sort by asc

func (Serializer) AssignExpr

func (e Serializer) AssignExpr() expression

func (Serializer) Avg

func (e Serializer) Avg() Number[float64]

func (Serializer) BeCond

func (e Serializer) BeCond() interface{}

func (Serializer) Build

func (e Serializer) Build(builder clause.Builder)

func (Serializer) BuildColumn

func (e Serializer) BuildColumn(stmt *gorm.Statement, opts ...BuildOpt) sql

func (Serializer) BuildWithArgs

func (e Serializer) BuildWithArgs(stmt *gorm.Statement) (sql, []interface{})

func (Serializer) ColumnName

func (e Serializer) ColumnName() sql

func (Serializer) ConcatCol

func (e Serializer) ConcatCol(cols ...Expr) Expr

func (Serializer) CondError

func (Serializer) CondError() error

func (Serializer) Count

func (e Serializer) Count() Number[int]

func (Serializer) Desc

func (e Serializer) Desc() Expr

Desc sort by desc

func (Serializer) Distinct

func (e Serializer) Distinct() Number[int]

func (Serializer) DivCol

func (e Serializer) DivCol(col Expr) Expr

func (Serializer) Eq

Eq judge equal

func (Serializer) EqCol

func (e Serializer) EqCol(col Expr) Expr

======================== comparison between columns ========================

func (Serializer) GroupConcat

func (e Serializer) GroupConcat() Expr

func (Serializer) Gt

Gt ...

func (Serializer) GtCol

func (e Serializer) GtCol(col Expr) Expr

func (Serializer) Gte

Gte ...

func (Serializer) GteCol

func (e Serializer) GteCol(col Expr) Expr

func (Serializer) IfNull

func (field Serializer) IfNull(value schema.SerializerValuerInterface) Expr

IfNull ...

func (Serializer) In

func (field Serializer) In(values ...schema.SerializerValuerInterface) Expr

In ...

func (Serializer) IsNotNull

func (e Serializer) IsNotNull() Expr

func (Serializer) IsNull

func (e Serializer) IsNull() Expr

func (Serializer) Length

func (e Serializer) Length() Number[int]

func (Serializer) Like

func (field Serializer) Like(value schema.SerializerValuerInterface) Expr

Like ...

func (Serializer) Lt

Lt ...

func (Serializer) LtCol

func (e Serializer) LtCol(col Expr) Expr

func (Serializer) Lte

Lte ...

func (Serializer) LteCol

func (e Serializer) LteCol(col Expr) Expr

func (Serializer) Max

func (e Serializer) Max() Number[float64]

func (Serializer) Min

func (e Serializer) Min() Number[float64]

func (Serializer) MulCol

func (e Serializer) MulCol(col Expr) Expr

func (Serializer) Neq

Neq judge not equal

func (Serializer) NeqCol

func (e Serializer) NeqCol(col Expr) Expr

func (Serializer) Null

func (e Serializer) Null() AssignExpr

func (Serializer) RawExpr

func (e Serializer) RawExpr() expression

func (Serializer) SetCol

func (e Serializer) SetCol(col Expr) AssignExpr

func (Serializer) SubCol

func (e Serializer) SubCol(col Expr) Expr

func (Serializer) Sum

func (field Serializer) Sum() Number[float64]

Sum ...

func (Serializer) Value

Value ...

func (Serializer) WithTable

func (e Serializer) WithTable(table string) Expr

======================== basic function ========================

type String

type String = Chars[string]

String string type field

func NewString

func NewString(table, column string, opts ...Option) String

NewString ...

type Tag

type Tag map[string]string

func (Tag) Build

func (tag Tag) Build() string

func (Tag) Remove

func (tag Tag) Remove(key string) Tag

func (Tag) Set

func (tag Tag) Set(key, value string) Tag

type TagBuilder

type TagBuilder interface {
	Build() string
}

type Time

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

Time time type field

func NewTime

func NewTime(table, column string, opts ...Option) Time

NewTime ...

func (Time) Add

func (field Time) Add(value time.Duration) Time

Add ...

func (Time) Between

func (field Time) Between(left time.Time, right time.Time) Expr

Between ...

func (Time) CurDate

func (field Time) CurDate() Time

CurDate return result of CURDATE()

func (Time) CurTime

func (field Time) CurTime() Time

CurTime return result of CURTIME()

func (Time) Date

func (field Time) Date() Time

Date convert to data, equal to "DATE(time_expr)"

func (Time) DateDiff

func (field Time) DateDiff(value time.Time) Number[int]

DateDiff equal to DATADIFF(self, value)

func (Time) DateFormat

func (field Time) DateFormat(value string) String

DateFormat equal to DATE_FORMAT(self, value)

func (Time) Day

func (field Time) Day() Number[int]

Day equal to DAY(self)

func (Time) DayName

func (field Time) DayName() String

DayName equal to DAYNAME(self)

func (Time) DayOfMonth

func (field Time) DayOfMonth() Number[int]

DayOfMonth equal to DAYOFMONTH(self)

func (Time) DayOfWeek

func (field Time) DayOfWeek() Number[int]

DayOfWeek equal to DAYOFWEEK(self)

func (Time) DayOfYear

func (field Time) DayOfYear() Number[int]

DayOfYear equal to DAYOFYEAR(self)

func (Time) Eq

func (field Time) Eq(value T) Expr

Eq judge equal

func (Time) Field

func (field Time) Field(value []interface{}) Expr

Field ...

func (Time) FromDays

func (field Time) FromDays(value int) Time

FromDays equal to FROM_DAYS(self)

func (Time) FromUnixTime

func (field Time) FromUnixTime(value int) Time

FromUnixTime equal to FROM_UNIXTIME(self)

func (Time) Gt

func (field Time) Gt(value T) Expr

Gt ...

func (Time) Gte

func (field Time) Gte(value T) Expr

Gte ...

func (Time) Hour

func (field Time) Hour() Number[int]

Hour equal to HOUR(self)

func (Time) IfNull

func (field Time) IfNull(value T) Expr

IfNull ...

func (Time) In

func (field Time) In(values ...T) Expr

In ...

func (Time) Like

func (field Time) Like(value string) Expr

Like ...

func (Time) Lt

func (field Time) Lt(value T) Expr

Lt ...

func (Time) Lte

func (field Time) Lte(value T) Expr

Lte ...

func (Time) MicroSecond

func (field Time) MicroSecond() Number[int]

MicroSecond equal to MICROSECOND(self)

func (Time) Minute

func (field Time) Minute() Number[int]

Minute equal to MINUTE(self)

func (Time) Month

func (field Time) Month() Number[int]

Month equal to MONTH(self)

func (Time) MonthName

func (field Time) MonthName() String

MonthName equal to MONTHNAME(self)

func (Time) Neq

func (field Time) Neq(value T) Expr

Neq judge not equal

func (Time) NotBetween

func (field Time) NotBetween(left time.Time, right time.Time) Expr

NotBetween ...

func (Time) NotIn

func (field Time) NotIn(values ...time.Time) Expr

NotIn ...

func (Time) NotLike

func (field Time) NotLike(value string) Expr

NotLike ...

func (Time) Now

func (field Time) Now() Time

Now return result of NOW()

func (Time) Second

func (field Time) Second() Number[int]

Second equal to SECOND(self)

func (Time) Sub

func (field Time) Sub(value time.Duration) Time

Sub ...

func (Time) Sum

func (field Time) Sum() genericsField[T]

Sum ...

func (Time) Value

func (field Time) Value(value T) AssignExpr

Value ...

func (Time) Year

func (field Time) Year() Number[int]

Year equal to YEAR(self)

func (Time) Zero

func (field Time) Zero() AssignExpr

Zero set zero value

type Uint

type Uint = Number[uint]

Uint type field

func NewUint

func NewUint(table, column string, opts ...Option) Uint

NewUint create new field for uint

type Uint8

type Uint8 = Number[uint8]

Uint8 type field

func NewUint8

func NewUint8(table, column string, opts ...Option) Uint8

NewUint8 create new field for uint8

type Uint16

type Uint16 = Number[uint16]

Uint16 type field

func NewUint16

func NewUint16(table, column string, opts ...Option) Uint16

NewUint16 create new field for uint16

type Uint32

type Uint32 = Number[uint32]

Uint32 type field

func NewUint32

func NewUint32(table, column string, opts ...Option) Uint32

NewUint32 create new field for uint32

type Uint64

type Uint64 = Number[uint64]

Uint64 type field

func NewUint64

func NewUint64(table, column string, opts ...Option) Uint64

NewUint64 create new field for uint64

type Value

type Value interface {

	// implement Condition
	BeCond() interface{}
	CondError() error
	// contains filtered or unexported methods
}

Value ...

func Values

func Values(value interface{}) Value

Values convert value to expression which implement Value

type ValuerType

type ValuerType struct {
	Column string
	Value  schema.SerializerValuerInterface
}

func (ValuerType) GormValue

func (v ValuerType) GormValue(ctx context.Context, db *gorm.DB) (expr clause.Expr)

Jump to

Keyboard shortcuts

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