rapier

package module
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 10 Imported by: 0

README

gorm-rapier

gorm-rapier is an assist rapier for gorm.

Go.Dev reference codecov Tests Go Report Card Licence Tag

Overview

  • Idiomatic and Reusable API from Dynamic Raw SQL
  • 100% Type-safe API without interface{}
  • Almost supports all features, plugins, DBMS that GORM supports
  • Almost same behavior as gorm you used.

Usage

Use go get.

go get github.com/thinkgos/gorm-rapier

Then import the package into your own code.

import "github.com/thinkgos/gorm-rapier"

Guide

Example

Reference

License

This project is under MIT License. See the LICENSE file for the full license text.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultPerPage 默认页大小
	DefaultPerPage = int64(50)
	// DefaultPageSize 默认最大页大小
	DefaultMaxPerPage = int64(500)
)
View Source
var All = Star
View Source
var One = NewRaw("1")

One a symbol of "1"

View Source
var Star = NewAsterisk("")

Star/All a symbol of "*"

View Source
var Zero = NewRaw("0")

Zero a symbol of "0"

Functions

func IntoExpression

func IntoExpression(conds ...Expr) []clause.Expression

IntoExpression convert Expr to clause.Expression

func IntoIntegerSlice

func IntoIntegerSlice[T constraints.Integer, R constraints.Integer](values []T) []R

func IntoSlice

func IntoSlice[T any, R any](values []T, f func(T) R) []R

func Paginate

func Paginate(page, perPage int64, maxPerPages ...int64) clause.Expression

Paginate 分页器 分页索引: page >= 1 分页大小: perPage >= 1 && <= DefaultMaxPerPage

Types

type AssignExpr added in v0.0.17

type AssignExpr interface {
	Expr

	SetExpr() any
}

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 new * field

func (Asterisk) As

func (e Asterisk) As(alias string) Expr

As use expr AS ?

func (Asterisk) Asc added in v0.0.9

func (e Asterisk) Asc() Expr

Asc use expr ASC

func (Asterisk) Avg

func (e Asterisk) Avg() Float64

Avg use AVG(expr)

func (Asterisk) Build

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

func (Asterisk) BuildColumn

func (e Asterisk) BuildColumn(stmt *gorm.Statement, opts ...BuildOption) string

func (Asterisk) BuildWithArgs

func (e Asterisk) BuildWithArgs(stmt *gorm.Statement) (string, []any)

func (Asterisk) ColumnName

func (e Asterisk) ColumnName() string

func (Asterisk) Count

func (a Asterisk) Count() Asterisk

Count use COUNT(expr)

func (Asterisk) Desc

func (e Asterisk) Desc() Expr

Desc use expr DESC

func (Asterisk) Distinct

func (a Asterisk) Distinct() Asterisk

Distinct use DISTINCT expr

func (Asterisk) EqCol

func (e Asterisk) EqCol(e2 Expr) Expr

EqCol use expr1 = expr2

func (Asterisk) EqSubQuery

func (e Asterisk) EqSubQuery(subQuery *gorm.DB) Expr

EqSubQuery use expr1 = (subQuery)

func (Asterisk) Expression

func (e Asterisk) Expression() clause.Expression

func (Asterisk) FieldName

func (e Asterisk) FieldName(prefixes ...string) string

FieldName hold column name. if prefixes not exist returns same as ColumnName(), others {prefixes[0]}_{ColumnName}

func (Asterisk) FindInSetCol

func (e Asterisk) FindInSetCol(e2 Expr) Expr

FindInSetCol use FIND_IN_SET(expr1, expr2)

func (Asterisk) FindInSetColWith

func (e Asterisk) FindInSetColWith(e2 Expr) Expr

FindInSetColWith use FIND_IN_SET(expr2, expr1)

func (Asterisk) FindInSetSubQuery

func (e Asterisk) FindInSetSubQuery(subQuery *gorm.DB) Expr

FindInSetSubQuery FIND_IN_SET(column, (subQuery))

func (Asterisk) GroupConcat

func (e Asterisk) GroupConcat() Expr

GroupConcat use GROUP_CONCAT(expr)

func (Asterisk) GtCol

func (e Asterisk) GtCol(e2 Expr) Expr

GtCol use expr1 > expr2

func (Asterisk) GtSubQuery

func (e Asterisk) GtSubQuery(subQuery *gorm.DB) Expr

GtSubQuery use expr1 > (subQuery)

func (Asterisk) GteCol

func (e Asterisk) GteCol(e2 Expr) Expr

GteCol use expr1 >= expr2

func (Asterisk) GteSubQuery

func (e Asterisk) GteSubQuery(subQuery *gorm.DB) Expr

GteSubQuery use expr1 >= (subQuery)

func (Asterisk) InSubQuery

func (e Asterisk) InSubQuery(subQuery *gorm.DB) Expr

InSubQuery use expr1 IN (subQuery)

func (Asterisk) IsNotNull

func (e Asterisk) IsNotNull() Expr

IsNotNull use `expr IS NOT NULL`

func (Asterisk) IsNull

func (e Asterisk) IsNull() Expr

IsNull use expr IS NULL

func (Asterisk) Length

func (e Asterisk) Length() Int

Length use LENGTH(expr)

func (Asterisk) LtCol

func (e Asterisk) LtCol(e2 Expr) Expr

LtCol use expr1 < expr2

func (Asterisk) LtSubQuery

func (e Asterisk) LtSubQuery(subQuery *gorm.DB) Expr

LtSubQuery use expr1 < (subQuery)

func (Asterisk) LteCol

func (e Asterisk) LteCol(e2 Expr) Expr

LteCol use expr1 <= expr2

func (Asterisk) LteSubQuery

func (e Asterisk) LteSubQuery(subQuery *gorm.DB) Expr

LteSubQuery use expr1 <= (subQuery)

func (Asterisk) Max

func (e Asterisk) Max() Float64

Max use MAX(expr)

func (Asterisk) Min

func (e Asterisk) Min() Float64

Min use MIN(expr)

func (Asterisk) NeqCol

func (e Asterisk) NeqCol(e2 Expr) Expr

NeqCol use expr1 <> expr2

func (Asterisk) NeqSubQuery

func (e Asterisk) NeqSubQuery(subQuery *gorm.DB) Expr

NeqSubQuery use expr1 <> (subQuery)

func (Asterisk) NotInSubQuery

func (e Asterisk) NotInSubQuery(subQuery *gorm.DB) Expr

NotInSubQuery use expr1 NOT IN (subQuery)

func (Asterisk) RawExpr

func (e Asterisk) RawExpr() any

func (Asterisk) SetCol

func (e Asterisk) SetCol(e2 Expr) AssignExpr

SetCol expr1=expr2

func (Asterisk) SetExpr

func (e Asterisk) SetExpr() any

func (Asterisk) SetSubQuery

func (e Asterisk) SetSubQuery(subQuery *gorm.DB) AssignExpr

SetSubQuery set with subQuery

func (Asterisk) ValueAny

func (e Asterisk) ValueAny(value any) AssignExpr

ValueAny set any value.

func (Asterisk) ValueNull

func (e Asterisk) ValueNull() AssignExpr

ValueNull set value NULL

func (Asterisk) ValueSubQuery added in v0.0.11

func (e Asterisk) ValueSubQuery(subQuery *gorm.DB) AssignExpr

ValueSubQuery set with subQuery same as SetSubQuery.

func (Asterisk) WithTable

func (e Asterisk) WithTable(table string) Expr

type Bool

type Bool Field

Bool boolean type field

func NewBool

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

NewBool new bool field.

func (Bool) And

func (field Bool) And(value bool) Expr

And use expr AND ?

func (Bool) BitAnd

func (field Bool) BitAnd(value bool) Expr

BitAnd use expr expr&?

func (Bool) BitOr

func (field Bool) BitOr(value bool) Expr

BitOr use expr expr|?

func (Bool) BitXor

func (field Bool) BitXor(value bool) Expr

BitXor use expr expr^?

func (Bool) Eq

func (field Bool) Eq(value bool) Expr

Eq equal to, use expr = ?

func (Bool) FindInSet

func (field Bool) FindInSet(targetList string) Expr

FindInSet use FIND_IN_SET(expr, ?)

func (Bool) IfNull

func (field Bool) IfNull(value bool) Expr

IfNull use IFNULL(expr,?)

func (Bool) Is

func (field Bool) Is(value bool) Expr

Is use expr = ?

func (Bool) Neq

func (field Bool) Neq(value bool) Expr

Neq not equal to, use expr <> ?

func (Bool) Not

func (field Bool) Not() Expr

Not use NOT expr

func (Bool) NullIf added in v0.0.10

func (field Bool) NullIf(value bool) Expr

NullIf use NULLIF(expr,?)

func (Bool) Or

func (field Bool) Or(value bool) Expr

Or use expr OR ?

func (Bool) Value

func (field Bool) Value(value bool) AssignExpr

Value set value

func (Bool) ValuePointer

func (field Bool) ValuePointer(value *bool) AssignExpr

Value set value use pointer

func (Bool) ValueZero

func (field Bool) ValueZero() AssignExpr

ValueZero set value zero

func (Bool) Xor

func (field Bool) Xor(value bool) Expr

Xor use expr XOR ?

type BuildOption

type BuildOption uint

BuildOption build option

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

	// WithAll build column with table and alias(if have)
	WithAll

	// WithoutQuote build column without quote
	WithoutQuote
)

type Bytes

type Bytes Field

Bytes []byte type field

func NewBytes

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

NewBytes new bytes field.

func (Bytes) Between

func (field Bytes) Between(left []byte, right []byte) Expr

Between use expr BETWEEN ? AND ?

func (Bytes) Eq

func (field Bytes) Eq(value []byte) Expr

Eq equal to, use expr = ?

func (Bytes) FindInSet

func (field Bytes) FindInSet(targetList string) Expr

FindInSet FIND_IN_SET(expr, ?)

func (Bytes) FindInSetWith

func (field Bytes) FindInSetWith(target string) Expr

FindInSetWith FIND_IN_SET(?, expr)

func (Bytes) FuzzyLike

func (field Bytes) FuzzyLike(value string) Expr

FuzzyLike use expr LIKE ?, ? contain prefix % and suffix % e.g. expr LIKE %value%

func (Bytes) Gt

func (field Bytes) Gt(value []byte) Expr

Gt greater than, use expr > ?

func (Bytes) Gte

func (field Bytes) Gte(value []byte) Expr

Gte greater or equal to, use expr >= ?

func (Bytes) IfNull

func (field Bytes) IfNull(value []byte) Expr

IfNull use IFNULL(expr,?)

func (Bytes) In

func (field Bytes) In(values ...[]byte) Expr

In use expr IN (?)

func (Bytes) InAny

func (field Bytes) InAny(value any) Expr

InAny use expr IN (?) value must be a array/slice

func (Bytes) IntoField

func (field Bytes) IntoField() Field

IntoField convert into Field. then use Field abilities.

func (Bytes) LeftLike

func (field Bytes) LeftLike(value string) Expr

LeftLike use expr LIKE ?, ? contain suffix %. e.g. expr LIKE value%

func (Bytes) Like

func (field Bytes) Like(value string) Expr

Like use expr LIKE ?

func (Bytes) Lt

func (field Bytes) Lt(value []byte) Expr

Lt less than, use expr < ?

func (Bytes) Lte

func (field Bytes) Lte(value []byte) Expr

Lte less or equal to, use expr <= ?

func (Bytes) Neq

func (field Bytes) Neq(value []byte) Expr

Neq not equal to, use expr <> ?

func (Bytes) NotBetween

func (field Bytes) NotBetween(left []byte, right []byte) Expr

NotBetween use NOT (expr BETWEEN ? AND ?)

func (Bytes) NotIn

func (field Bytes) NotIn(values ...[]byte) Expr

NotIn use expr NOT IN (?)

func (Bytes) NotInAny

func (field Bytes) NotInAny(value any) Expr

NotInAny use expr NOT IN (?) value must be a array/slice

func (Bytes) NotLike

func (field Bytes) NotLike(value string) Expr

NotLike use expr NOT LIKE ?

func (Bytes) NotRegxp

func (field Bytes) NotRegxp(value string) Expr

NotRegxp use NOT expr REGEXP ?

func (Bytes) NullIf added in v0.0.10

func (field Bytes) NullIf(value []byte) Expr

NullIf use NULLIF(expr,?)

func (Bytes) Regexp

func (field Bytes) Regexp(value string) Expr

Regexp use expr REGEXP ?

func (Bytes) SubstringIndex

func (field Bytes) SubstringIndex(delim string, count int) Bytes

SubstringIndex use SUBSTRING_INDEX(expr,?,?) https://dev.mysql.com/doc/refman/8.0/en/functions.html#function_substring-index

func (Bytes) Value

func (field Bytes) Value(value []byte) AssignExpr

Value set value

func (Bytes) ValueZero

func (field Bytes) ValueZero() AssignExpr

ValueZero set value zero

type CaseWhen

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

func NewCaseWhen

func NewCaseWhen() *CaseWhen

NewCaseWhen new case when clause CASE

WHEN condition1 THEN result1
WHEN condition2 THEN result2
...
[ELSE result]

END

func (*CaseWhen) Build

func (c *CaseWhen) Build() Field

func (*CaseWhen) Else

func (c *CaseWhen) Else(result Expr) *CaseWhen

Else add `ELSE result“

func (*CaseWhen) WhenThen

func (c *CaseWhen) WhenThen(condition Expr, result Expr) *CaseWhen

WhenThen add `WHEN condition THEN result`

type Columns

type Columns []Expr

Columns columns array

func NewColumns

func NewColumns(cols ...Expr) Columns

NewColumns new columns instance.

func (Columns) In

func (cs Columns) In(subQueryOrValue any) Expr

IN return contains subQuery or value when len(columns) == 1, equal to columns[0] IN (subQuery/value) when len(columns) > 1, equal to (columns[0], columns[1], ...) IN (subQuery/value)

func (Columns) NotIn

func (cs Columns) NotIn(subQueryOrValue any) Expr

IN return contains subQuery or value when len(columns) == 1, equal to NOT columns[0] IN (subQuery/value) when len(columns) > 1, equal to NOT (columns[0], columns[1], ...) IN (subQuery/value)

func (Columns) Set

func (cs Columns) Set(subQuery *gorm.DB) AssignExpr

SetSubQuery set with subQuery

type Condition

type Condition = func(*gorm.DB) *gorm.DB

Condition alias func(*gorm.DB) *gorm.DB

func CrossJoinsExpr

func CrossJoinsExpr(table schema.Tabler, conds ...Expr) Condition

CrossJoinsExpr cross joins condition

func CrossJoinsXExpr deprecated

func CrossJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) Condition

Deprecated: use other CrossJoinsExpr(NewJoinTable(table, alias), conds...). CrossJoinsXExpr cross joins condition

func DistinctExpr

func DistinctExpr(columns ...Expr) Condition

DistinctExpr with field

func GormClauses

func GormClauses(conds ...clause.Expression) Condition

func GormDistinct

func GormDistinct(args ...any) Condition

func GormGroup

func GormGroup(name string) Condition

func GormHaving

func GormHaving(query any, args ...any) Condition

func GormInnerJoins

func GormInnerJoins(query string, args ...any) Condition

func GormJoins

func GormJoins(query string, args ...any) Condition

func GormLimit

func GormLimit(limit int) Condition

func GormNot

func GormNot(query any, args ...any) Condition

func GormOffset

func GormOffset(offset int) Condition

func GormOmit

func GormOmit(columns ...string) Condition

func GormOr

func GormOr(query any, args ...any) Condition

func GormOrder

func GormOrder(value any) Condition

func GormPreload

func GormPreload(query string, args ...any) Condition

func GormSelect

func GormSelect(query any, args ...any) Condition

func GormTable

func GormTable(name string, args ...any) Condition

func GormUnscoped

func GormUnscoped() Condition

func GormWhere

func GormWhere(query any, args ...any) Condition

func GromModel added in v0.0.9

func GromModel[T any]() Condition

func GroupExpr

func GroupExpr(columns ...Expr) Condition

GroupExpr with field

func InnerJoinsExpr

func InnerJoinsExpr(table schema.Tabler, conds ...Expr) Condition

InnerJoinsExpr inner joins condition

func InnerJoinsXExpr deprecated

func InnerJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) Condition

Deprecated: use other InnerJoinsExpr(NewJoinTable(table, alias), conds...). InnerJoinsXExpr inner joins condition

func LeftJoinsExpr

func LeftJoinsExpr(table schema.Tabler, conds ...Expr) Condition

LeftJoinsExpr left join condition

func LeftJoinsXExpr deprecated

func LeftJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) Condition

Deprecated: use other LeftJoinsExpr(NewJoinTable(table, alias), conds...). LeftJoinsXExpr left join condition

func LockingShare

func LockingShare() Condition

LockingShare specify the lock strength to SHARE

func LockingUpdate

func LockingUpdate() Condition

LockingUpdate specify the lock strength to UPDATE

func OmitExpr

func OmitExpr(columns ...Expr) Condition

OmitExpr with field

func OrderExpr

func OrderExpr(columns ...Expr) Condition

OrderExpr with field

func Pagination

func Pagination(page, perPage int64, maxPerPages ...int64) Condition

Pagination 分页器 分页索引: page >= 1 分页大小: perPage >= 1 && <= DefaultMaxPerPage

func RightJoinsExpr

func RightJoinsExpr(table schema.Tabler, conds ...Expr) Condition

RightJoinsExpr right join condition

func RightJoinsXExpr deprecated

func RightJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) Condition

Deprecated: use other RightJoinsExpr(NewJoinTable(table, alias), conds...). RightJoinsXExpr right join condition

func SelectExpr

func SelectExpr(columns ...Expr) Condition

SelectExpr with field

func TableExpr

func TableExpr(fromSubs ...From) Condition

TableExpr return a table produced by SubQuery.

type Conditions

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

Conditions hold Condition slice

func NewConditions

func NewConditions(cs ...Condition) *Conditions

NewConditions new condition instance.

func (*Conditions) Build

func (c *Conditions) Build() []Condition

Table with field

func (*Conditions) Clauses

func (c *Conditions) Clauses(conds ...clause.Expression) *Conditions

func (*Conditions) Configure

func (c *Conditions) Configure(funcs ...func(*Conditions) *Conditions) *Conditions

Configure the conditions in the scope

func (*Conditions) CrossJoinsExpr

func (c *Conditions) CrossJoinsExpr(table schema.Tabler, conds ...Expr) *Conditions

CrossJoinsExpr cross joins condition

func (*Conditions) CrossJoinsXExpr deprecated

func (c *Conditions) CrossJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Conditions

Deprecated: use other CrossJoinsExpr(NewJoinTable(table, alias), conds...). CrossJoinsXExpr cross joins condition

func (*Conditions) Distinct

func (c *Conditions) Distinct(args ...any) *Conditions

Distinct with field

func (*Conditions) DistinctExpr

func (c *Conditions) DistinctExpr(columns ...Expr) *Conditions

DistinctExpr with field

func (*Conditions) Group

func (c *Conditions) Group(name string) *Conditions

func (*Conditions) GroupExpr

func (c *Conditions) GroupExpr(columns ...Expr) *Conditions

GroupExpr with field

func (*Conditions) Having

func (c *Conditions) Having(query any, args ...any) *Conditions

func (*Conditions) InnerJoins

func (c *Conditions) InnerJoins(query string, args ...any) *Conditions

func (*Conditions) InnerJoinsExpr

func (c *Conditions) InnerJoinsExpr(table schema.Tabler, conds ...Expr) *Conditions

InnerJoinsExpr inner joins condition

func (*Conditions) InnerJoinsXExpr deprecated

func (c *Conditions) InnerJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Conditions

Deprecated: use other InnerJoinsExpr(NewJoinTable(table, alias), conds...). InnerJoinsXExpr inner joins condition

func (*Conditions) Joins

func (c *Conditions) Joins(query string, args ...any) *Conditions

func (*Conditions) LeftJoinsExpr

func (c *Conditions) LeftJoinsExpr(table schema.Tabler, conds ...Expr) *Conditions

LeftJoinsExpr left join condition

func (*Conditions) LeftJoinsXExpr deprecated

func (c *Conditions) LeftJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Conditions

Deprecated: use other LeftJoinsExpr(NewJoinTable(table, alias), conds...). LeftJoinsXExpr left join condition

func (*Conditions) Limit

func (c *Conditions) Limit(limit int) *Conditions

func (*Conditions) LockingShare

func (c *Conditions) LockingShare() *Conditions

LockingShare specify the lock strength to SHARE

func (*Conditions) LockingUpdate

func (c *Conditions) LockingUpdate() *Conditions

LockingUpdate specify the lock strength to UPDATE

func (*Conditions) Not

func (c *Conditions) Not(query any, args ...any) *Conditions

func (*Conditions) Offset

func (c *Conditions) Offset(offset int) *Conditions

func (*Conditions) Omit

func (c *Conditions) Omit(columns ...string) *Conditions

func (*Conditions) OmitExpr

func (c *Conditions) OmitExpr(columns ...Expr) *Conditions

OmitExpr with field

func (*Conditions) Or

func (c *Conditions) Or(query any, args ...any) *Conditions

func (*Conditions) Order

func (c *Conditions) Order(value any) *Conditions

func (*Conditions) OrderExpr

func (c *Conditions) OrderExpr(columns ...Expr) *Conditions

OrderExpr with field

func (*Conditions) Pagination

func (c *Conditions) Pagination(page, perPage int64, maxPages ...int64) *Conditions

Pagination 分页器 分页索引: page >= 1 分页大小: perPage >= 1 && <= DefaultMaxPerPage

func (*Conditions) Preload

func (c *Conditions) Preload(query string, args ...any) *Conditions

func (*Conditions) RightJoinsExpr

func (c *Conditions) RightJoinsExpr(table schema.Tabler, conds ...Expr) *Conditions

RightJoinsExpr right join condition

func (*Conditions) RightJoinsXExpr deprecated

func (c *Conditions) RightJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Conditions

Deprecated: use other RightJoinsExpr(NewJoinTable(table, alias), conds...). RightJoinsXExpr right join condition

func (*Conditions) Scopes

func (c *Conditions) Scopes(cs ...Condition) *Conditions

Scopes more condition

func (*Conditions) Select

func (c *Conditions) Select(query any, args ...any) *Conditions

Select with field

func (*Conditions) SelectExpr

func (c *Conditions) SelectExpr(columns ...Expr) *Conditions

SelectExpr with field

func (*Conditions) Unscoped

func (c *Conditions) Unscoped() *Conditions

func (*Conditions) Where

func (c *Conditions) Where(query any, args ...any) *Conditions

type Decimal

type Decimal = Float[string]

func NewDecimal

func NewDecimal(table, column string, opts ...Option) Decimal

NewDecimal new decimal field

type Executor

type Executor[T any] struct {
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor[T any](db *gorm.DB) *Executor[T]

Executor new executor

func (*Executor[T]) Assign

func (x *Executor[T]) Assign(attrs ...any) *Executor[T]

Assign provide attributes used in [FirstOrCreate] or [FirstOrInit]

func (*Executor[T]) AssignExpr

func (x *Executor[T]) AssignExpr(attrs ...AssignExpr) *Executor[T]

AssignExpr with AssignExpr provide attributes used in [FirstOrCreate] or [FirstOrInit]

func (*Executor[T]) Attrs

func (x *Executor[T]) Attrs(attrs ...any) *Executor[T]

Attrs provide attributes used in [FirstOrCreate] or [FirstOrInit]

func (*Executor[T]) AttrsExpr

func (x *Executor[T]) AttrsExpr(attrs ...AssignExpr) *Executor[T]

AttrsExpr with AssignExpr provide attributes used in [FirstOrCreate] or [FirstOrInit]

func (*Executor[T]) Clauses

func (x *Executor[T]) Clauses(conds ...clause.Expression) *Executor[T]

func (*Executor[T]) Count

func (x *Executor[T]) Count() (count int64, err error)

func (*Executor[T]) Create

func (x *Executor[T]) Create(values ...*T) error

func (*Executor[T]) CreateInBatches

func (x *Executor[T]) CreateInBatches(value []*T, batchSize int) error

func (*Executor[T]) CrossJoinsExpr

func (x *Executor[T]) CrossJoinsExpr(table schema.Tabler, conds ...Expr) *Executor[T]

func (*Executor[T]) CrossJoinsXExpr deprecated

func (x *Executor[T]) CrossJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Executor[T]

Deprecated: use other CrossJoinsExpr(NewJoinTable(table, alias), conds...).

func (*Executor[T]) Debug

func (x *Executor[T]) Debug() *Executor[T]

func (*Executor[T]) Delete

func (x *Executor[T]) Delete() (rowsAffected int64, err error)

func (*Executor[T]) Distinct

func (x *Executor[T]) Distinct(args ...any) *Executor[T]

func (*Executor[T]) DistinctExpr

func (x *Executor[T]) DistinctExpr(columns ...Expr) *Executor[T]

func (*Executor[T]) Exist

func (x *Executor[T]) Exist() (exist bool, err error)

func (*Executor[T]) Find

func (x *Executor[T]) Find(dest any) error

func (*Executor[T]) FindAll

func (x *Executor[T]) FindAll() (rows []*T, err error)

func (*Executor[T]) FindAllByPage added in v0.0.16

func (x *Executor[T]) FindAllByPage(offset, limit int) (rows []*T, count int64, err error)

func (*Executor[T]) FindAllPaginate added in v0.0.16

func (x *Executor[T]) FindAllPaginate(page, perPage int64, maxPerPages ...int64) (rows []*T, count int64, err error)

func (*Executor[T]) FindByPage added in v0.0.16

func (x *Executor[T]) FindByPage(dest any, offset, limit int) (count int64, err error)

func (*Executor[T]) FindInBatches

func (x *Executor[T]) FindInBatches(dest any, batchSize int, fc func(tx *gorm.DB, batch int) error) error

func (*Executor[T]) FindPaginate added in v0.0.16

func (x *Executor[T]) FindPaginate(dest any, page, perPage int64, maxPerPages ...int64) (count int64, err error)

func (*Executor[T]) First

func (x *Executor[T]) First(dest any) error

func (*Executor[T]) FirstBool

func (x *Executor[T]) FirstBool() (v bool, err error)

func (*Executor[T]) FirstFloat32

func (x *Executor[T]) FirstFloat32() (v float32, err error)

func (*Executor[T]) FirstFloat64

func (x *Executor[T]) FirstFloat64() (v float64, err error)

func (*Executor[T]) FirstInt

func (x *Executor[T]) FirstInt() (v int, err error)

func (*Executor[T]) FirstInt16

func (x *Executor[T]) FirstInt16() (v int16, err error)

func (*Executor[T]) FirstInt32

func (x *Executor[T]) FirstInt32() (v int32, err error)

func (*Executor[T]) FirstInt64

func (x *Executor[T]) FirstInt64() (v int64, err error)

func (*Executor[T]) FirstInt8

func (x *Executor[T]) FirstInt8() (v int8, err error)

func (*Executor[T]) FirstOne

func (x *Executor[T]) FirstOne() (*T, error)

func (*Executor[T]) FirstOrCreate

func (x *Executor[T]) FirstOrCreate() (*T, error)

func (*Executor[T]) FirstOrInit

func (x *Executor[T]) FirstOrInit() (*T, error)

func (*Executor[T]) FirstString

func (x *Executor[T]) FirstString() (v string, err error)

func (*Executor[T]) FirstUint

func (x *Executor[T]) FirstUint() (v uint, err error)

func (*Executor[T]) FirstUint16

func (x *Executor[T]) FirstUint16() (v uint16, err error)

func (*Executor[T]) FirstUint32

func (x *Executor[T]) FirstUint32() (v uint32, err error)

func (*Executor[T]) FirstUint64

func (x *Executor[T]) FirstUint64() (v uint64, err error)

func (*Executor[T]) FirstUint8

func (x *Executor[T]) FirstUint8() (v uint8, err error)

func (*Executor[T]) Group

func (x *Executor[T]) Group(name string) *Executor[T]

func (*Executor[T]) GroupExpr

func (x *Executor[T]) GroupExpr(columns ...Expr) *Executor[T]

func (*Executor[T]) Having

func (x *Executor[T]) Having(query any, args ...any) *Executor[T]

func (*Executor[T]) InnerJoins

func (x *Executor[T]) InnerJoins(query string, args ...any) *Executor[T]

func (*Executor[T]) InnerJoinsExpr

func (x *Executor[T]) InnerJoinsExpr(table schema.Tabler, conds ...Expr) *Executor[T]

func (*Executor[T]) InnerJoinsXExpr deprecated

func (x *Executor[T]) InnerJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Executor[T]

Deprecated: use other InnerJoinsExpr(NewJoinTable(table, alias), conds...).

func (*Executor[T]) IntoDB

func (x *Executor[T]) IntoDB() *gorm.DB

IntoDB with model or table

func (*Executor[T]) IntoExistExpr

func (x *Executor[T]) IntoExistExpr() Expr

func (*Executor[T]) IntoNotExistExpr

func (x *Executor[T]) IntoNotExistExpr() Expr

func (*Executor[T]) IntoRawDB

func (x *Executor[T]) IntoRawDB() *gorm.DB

IntoRawDB without model or table

func (*Executor[T]) IntoSubQueryExpr

func (x *Executor[T]) IntoSubQueryExpr() Field

func (*Executor[T]) Joins

func (x *Executor[T]) Joins(query string, args ...any) *Executor[T]

func (*Executor[T]) Last

func (x *Executor[T]) Last(dest any) error

func (*Executor[T]) LastOne

func (x *Executor[T]) LastOne() (*T, error)

func (*Executor[T]) LeftJoinsExpr

func (x *Executor[T]) LeftJoinsExpr(table schema.Tabler, conds ...Expr) *Executor[T]

func (*Executor[T]) LeftJoinsXExpr deprecated

func (x *Executor[T]) LeftJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Executor[T]

Deprecated: use other LeftJoinsExpr(NewJoinTable(table, alias), conds...).

func (*Executor[T]) Limit

func (x *Executor[T]) Limit(limit int) *Executor[T]

func (*Executor[T]) LockingShare

func (x *Executor[T]) LockingShare() *Executor[T]

func (*Executor[T]) LockingUpdate

func (x *Executor[T]) LockingUpdate() *Executor[T]

func (*Executor[T]) Model added in v0.0.9

func (x *Executor[T]) Model() *Executor[T]

func (*Executor[T]) Not

func (x *Executor[T]) Not(query any, args ...any) *Executor[T]

func (*Executor[T]) Offset

func (x *Executor[T]) Offset(offset int) *Executor[T]

func (*Executor[T]) Omit

func (x *Executor[T]) Omit(columns ...string) *Executor[T]

func (*Executor[T]) OmitExpr

func (x *Executor[T]) OmitExpr(columns ...Expr) *Executor[T]

func (*Executor[T]) Or

func (x *Executor[T]) Or(query any, args ...any) *Executor[T]

func (*Executor[T]) Order

func (x *Executor[T]) Order(value any) *Executor[T]

func (*Executor[T]) OrderExpr

func (x *Executor[T]) OrderExpr(columns ...Expr) *Executor[T]

func (*Executor[T]) Pagination

func (x *Executor[T]) Pagination(page, perPage int64, maxPerPages ...int64) *Executor[T]

func (*Executor[T]) Pluck

func (x *Executor[T]) Pluck(column string, value any) error

func (*Executor[T]) PluckBool

func (x *Executor[T]) PluckBool(column string) (slice []bool, err error)

func (*Executor[T]) PluckExpr

func (x *Executor[T]) PluckExpr(column Expr, value any) error

func (*Executor[T]) PluckExprBool

func (x *Executor[T]) PluckExprBool(column Expr) (slice []bool, err error)

func (*Executor[T]) PluckExprInt

func (x *Executor[T]) PluckExprInt(column Expr) (slice []int, err error)

func (*Executor[T]) PluckExprInt16

func (x *Executor[T]) PluckExprInt16(column Expr) (slice []int16, err error)

func (*Executor[T]) PluckExprInt32

func (x *Executor[T]) PluckExprInt32(column Expr) (slice []int32, err error)

func (*Executor[T]) PluckExprInt64

func (x *Executor[T]) PluckExprInt64(column Expr) (slice []int64, err error)

func (*Executor[T]) PluckExprInt8

func (x *Executor[T]) PluckExprInt8(column Expr) (slice []int8, err error)

func (*Executor[T]) PluckExprString

func (x *Executor[T]) PluckExprString(column Expr) (slice []string, err error)

func (*Executor[T]) PluckExprUint

func (x *Executor[T]) PluckExprUint(column Expr) (slice []uint, err error)

func (*Executor[T]) PluckExprUint16

func (x *Executor[T]) PluckExprUint16(column Expr) (slice []uint16, err error)

func (*Executor[T]) PluckExprUint32

func (x *Executor[T]) PluckExprUint32(column Expr) (slice []uint32, err error)

func (*Executor[T]) PluckExprUint64

func (x *Executor[T]) PluckExprUint64(column Expr) (slice []uint64, err error)

func (*Executor[T]) PluckExprUint8

func (x *Executor[T]) PluckExprUint8(column Expr) (slice []uint8, err error)

func (*Executor[T]) PluckInt

func (x *Executor[T]) PluckInt(column string) (slice []int, err error)

func (*Executor[T]) PluckInt16

func (x *Executor[T]) PluckInt16(column string) (slice []int16, err error)

func (*Executor[T]) PluckInt32

func (x *Executor[T]) PluckInt32(column string) (slice []int32, err error)

func (*Executor[T]) PluckInt64

func (x *Executor[T]) PluckInt64(column string) (slice []int64, err error)

func (*Executor[T]) PluckInt8

func (x *Executor[T]) PluckInt8(column string) (slice []int8, err error)

func (*Executor[T]) PluckString

func (x *Executor[T]) PluckString(column string) (slice []string, err error)

func (*Executor[T]) PluckUint

func (x *Executor[T]) PluckUint(column string) (slice []uint, err error)

func (*Executor[T]) PluckUint16

func (x *Executor[T]) PluckUint16(column string) (slice []uint16, err error)

func (*Executor[T]) PluckUint32

func (x *Executor[T]) PluckUint32(column string) (slice []uint32, err error)

func (*Executor[T]) PluckUint64

func (x *Executor[T]) PluckUint64(column string) (slice []uint64, err error)

func (*Executor[T]) PluckUint8

func (x *Executor[T]) PluckUint8(column string) (slice []uint8, err error)

func (*Executor[T]) Preload

func (x *Executor[T]) Preload(query string, args ...any) *Executor[T]

func (*Executor[T]) Returning

func (x *Executor[T]) Returning(columns ...string) *Executor[T]

func (*Executor[T]) RightJoinsExpr

func (x *Executor[T]) RightJoinsExpr(table schema.Tabler, conds ...Expr) *Executor[T]

func (*Executor[T]) RightJoinsXExpr deprecated

func (x *Executor[T]) RightJoinsXExpr(table schema.Tabler, alias string, conds ...Expr) *Executor[T]

Deprecated: use other RightJoinsExpr(NewJoinTable(table, alias), conds...).

func (*Executor[T]) Save

func (x *Executor[T]) Save(value *T) (rowsAffected int64, err error)

func (*Executor[T]) Scan

func (x *Executor[T]) Scan(dest any) error

func (*Executor[T]) ScanBool

func (x *Executor[T]) ScanBool() (v bool, err error)

func (*Executor[T]) ScanFloat32

func (x *Executor[T]) ScanFloat32() (v float32, err error)

func (*Executor[T]) ScanFloat64

func (x *Executor[T]) ScanFloat64() (v float64, err error)

func (*Executor[T]) ScanInt

func (x *Executor[T]) ScanInt() (v int, err error)

func (*Executor[T]) ScanInt16

func (x *Executor[T]) ScanInt16() (v int16, err error)

func (*Executor[T]) ScanInt32

func (x *Executor[T]) ScanInt32() (v int32, err error)

func (*Executor[T]) ScanInt64

func (x *Executor[T]) ScanInt64() (v int64, err error)

func (*Executor[T]) ScanInt8

func (x *Executor[T]) ScanInt8() (v int8, err error)

func (*Executor[T]) ScanOne

func (x *Executor[T]) ScanOne() (*T, error)

func (*Executor[T]) ScanString

func (x *Executor[T]) ScanString() (v string, err error)

func (*Executor[T]) ScanUint

func (x *Executor[T]) ScanUint() (v uint, err error)

func (*Executor[T]) ScanUint16

func (x *Executor[T]) ScanUint16() (v uint16, err error)

func (*Executor[T]) ScanUint32

func (x *Executor[T]) ScanUint32() (v uint32, err error)

func (*Executor[T]) ScanUint64

func (x *Executor[T]) ScanUint64() (v uint64, err error)

func (*Executor[T]) ScanUint8

func (x *Executor[T]) ScanUint8() (v uint8, err error)

func (*Executor[T]) Scopes

func (x *Executor[T]) Scopes(cs ...Condition) *Executor[T]

func (*Executor[T]) Select

func (x *Executor[T]) Select(query any, args ...any) *Executor[T]

func (*Executor[T]) SelectExpr

func (x *Executor[T]) SelectExpr(columns ...Expr) *Executor[T]

func (*Executor[T]) Session

func (x *Executor[T]) Session(config *gorm.Session) *Executor[T]

func (*Executor[T]) Table

func (x *Executor[T]) Table(name string, args ...any) *Executor[T]

func (*Executor[T]) TableExpr

func (x *Executor[T]) TableExpr(fromSubs ...From) *Executor[T]

func (*Executor[T]) Take

func (x *Executor[T]) Take(dest any) error

func (*Executor[T]) TakeBool

func (x *Executor[T]) TakeBool() (v bool, err error)

func (*Executor[T]) TakeFloat32

func (x *Executor[T]) TakeFloat32() (v float32, err error)

func (*Executor[T]) TakeFloat64

func (x *Executor[T]) TakeFloat64() (v float64, err error)

func (*Executor[T]) TakeInt

func (x *Executor[T]) TakeInt() (v int, err error)

func (*Executor[T]) TakeInt16

func (x *Executor[T]) TakeInt16() (v int16, err error)

func (*Executor[T]) TakeInt32

func (x *Executor[T]) TakeInt32() (v int32, err error)

func (*Executor[T]) TakeInt64

func (x *Executor[T]) TakeInt64() (v int64, err error)

func (*Executor[T]) TakeInt8

func (x *Executor[T]) TakeInt8() (v int8, err error)

func (*Executor[T]) TakeOne

func (x *Executor[T]) TakeOne() (*T, error)

func (*Executor[T]) TakeString

func (x *Executor[T]) TakeString() (v string, err error)

func (*Executor[T]) TakeUint

func (x *Executor[T]) TakeUint() (v uint, err error)

func (*Executor[T]) TakeUint16

func (x *Executor[T]) TakeUint16() (v uint16, err error)

func (*Executor[T]) TakeUint32

func (x *Executor[T]) TakeUint32() (v uint32, err error)

func (*Executor[T]) TakeUint64

func (x *Executor[T]) TakeUint64() (v uint64, err error)

func (*Executor[T]) TakeUint8

func (x *Executor[T]) TakeUint8() (v uint8, err error)

func (*Executor[T]) Unscoped

func (x *Executor[T]) Unscoped() *Executor[T]

func (*Executor[T]) Update

func (x *Executor[T]) Update(column string, value any) (rowsAffected int64, err error)

func (*Executor[T]) UpdateColumn

func (x *Executor[T]) UpdateColumn(column string, value any) (rowsAffected int64, err error)

func (*Executor[T]) UpdateColumnExpr

func (x *Executor[T]) UpdateColumnExpr(column Expr, value any) (rowsAffected int64, err error)

func (*Executor[T]) UpdateColumns

func (x *Executor[T]) UpdateColumns(value *T) (rowsAffected int64, err error)

func (*Executor[T]) UpdateColumnsExpr

func (x *Executor[T]) UpdateColumnsExpr(columns ...AssignExpr) (rowsAffected int64, err error)

func (*Executor[T]) UpdateColumnsMap

func (x *Executor[T]) UpdateColumnsMap(value map[string]any) (rowsAffected int64, err error)

func (*Executor[T]) UpdateExpr

func (x *Executor[T]) UpdateExpr(column Expr, value any) (rowsAffected int64, err error)

func (*Executor[T]) Updates

func (x *Executor[T]) Updates(value *T) (rowsAffected int64, err error)

func (*Executor[T]) UpdatesExpr

func (x *Executor[T]) UpdatesExpr(columns ...AssignExpr) (rowsAffected int64, err error)

func (*Executor[T]) UpdatesMap

func (x *Executor[T]) UpdatesMap(value map[string]any) (rowsAffected int64, err error)

func (*Executor[T]) Where

func (x *Executor[T]) Where(query any, args ...any) *Executor[T]

func (*Executor[T]) WithContext

func (x *Executor[T]) WithContext(ctx context.Context) *Executor[T]

type Expr

type Expr interface {
	clause.Expression

	As(alias string) Expr
	ColumnName() string
	Expression() clause.Expression
	RawExpr() any
	BuildColumn(*gorm.Statement, ...BuildOption) string
	BuildWithArgs(*gorm.Statement) (query string, args []any)
}

Expr a query expression about field

func And

func And(exprs ...Expr) Expr

And return and condition form example: (`id1` AND `id2`)

func EmptyExpr

func EmptyExpr() Expr

EmptyExpr return a empty expression. it is nil

func Exist

func Exist(subQuery *gorm.DB) Expr

Exist equivalent EXISTS(subQuery)

func Not

func Not(exprs ...Expr) Expr

Not return not condition form example: NOT (`id1` AND `id2`)

func NotExist

func NotExist(subQuery *gorm.DB) Expr

NotExist equivalent NOT EXISTS(subQuery)

func Or

func Or(exprs ...Expr) Expr

Or return or condition form example: (`id1` OR `id2`)

type Field

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

Field a standard field struct

func ConcatCol added in v0.0.10

func ConcatCol(e Expr, es ...Expr) Field

CONCAT(expr1,expr2,...exprN)

func ConcatWsCol added in v0.0.10

func ConcatWsCol(separator Expr, e Expr, es ...Expr) Field

CONCAT_WS(separator,expr1,expr2,...exprN)

func IF added in v0.0.5

func IF(condition, value_if_true, value_if_false Expr) Field

func NewField

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

NewField new field

func SubQuery

func SubQuery(db *gorm.DB) Field

func (Field) Add

func (field Field) Add(value any) Field

Add use value type:

time.Duration: use DATE_ADD(expr, INTERVAL ? MICROSECOND)
other: use expr+?

func (Field) AddCol

func (e Field) AddCol(col Expr) Field

AddCol use expr1 + expr2

func (Field) As

func (e Field) As(alias string) Expr

As use expr AS ?

func (Field) Asc added in v0.0.9

func (e Field) Asc() Expr

Asc use expr ASC

func (Field) Avg

func (e Field) Avg() Float64

Avg use AVG(expr)

func (Field) Between

func (field Field) Between(left any, right any) Expr

Between use expr BETWEEN ? AND ?

func (Field) BitAnd

func (field Field) BitAnd(value any) Field

BitAnd use expr expr&?

func (Field) BitFlip

func (field Field) BitFlip() Field

BitFlip use expr ~expr

func (Field) BitOr

func (field Field) BitOr(value any) Field

BitOr use expr expr|?

func (Field) BitXor

func (field Field) BitXor(value any) Field

BitXor use expr expr^?

func (Field) Build

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

func (Field) BuildColumn

func (e Field) BuildColumn(stmt *gorm.Statement, opts ...BuildOption) string

func (Field) BuildWithArgs

func (e Field) BuildWithArgs(stmt *gorm.Statement) (string, []any)

func (Field) ColumnName

func (e Field) ColumnName() string

func (Field) Concat

func (field Field) Concat(before, after string) String

Concat use CONCAT(?,?,?)

func (Field) ConcatCol

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

ConcatCol use CONCAT(expr1,exp2...exprN)

func (Field) ConcatWsCol added in v0.0.10

func (field Field) ConcatWsCol(separator Expr, cols ...Expr) Field

ConcatWsCol use CONCAT_WS(separator,expr1,expr2,...exprN)

func (Field) Count

func (e Field) Count() Int

Count use COUNT(expr)

func (Field) Date

func (field Field) Date() Time

Date use DATE(expr) return the date.

func (Field) DateDiff

func (field Field) DateDiff(expr2 time.Time) Int

DateDiff use DATEDIFF(expr1, expr2)

func (Field) DateFormat

func (field Field) DateFormat(format string) String

DateFormat use DATE_FORMAT(date,format)

func (Field) Day

func (field Field) Day() Int

Day use DAY(date) return the day.

func (Field) DayName

func (field Field) DayName() String

DayName use DAYNAME(date) return the name of the day of the week.

func (Field) DayOfMonth

func (field Field) DayOfMonth() Int

DayOfMonth use DAYOFMONTH(date)

func (Field) DayOfWeek

func (field Field) DayOfWeek() Int

DayOfWeek use DAYOFWEEK(date)

func (Field) DayOfYear

func (field Field) DayOfYear() Int

DayOfYear use DAYOFYEAR(date)

func (Field) Desc

func (e Field) Desc() Expr

Desc use expr DESC

func (Field) Distinct

func (e Field) Distinct() Int

Distinct use DISTINCT(expr)

func (Field) Div

func (field Field) Div(value any) Field

Div use expr/?

func (Field) DivCol

func (e Field) DivCol(col Expr) Field

DivCol use (expr1) / (expr2)

func (Field) Eq

func (field Field) Eq(value any) Expr

Eq use expr = ?

func (Field) EqCol

func (e Field) EqCol(e2 Expr) Expr

EqCol use expr1 = expr2

func (Field) EqSubQuery

func (e Field) EqSubQuery(subQuery *gorm.DB) Expr

EqSubQuery use expr1 = (subQuery)

func (Field) Expression

func (e Field) Expression() clause.Expression

func (Field) FieldName

func (e Field) FieldName(prefixes ...string) string

FieldName hold column name. if prefixes not exist returns same as ColumnName(), others {prefixes[0]}_{ColumnName}

func (Field) FindInSet

func (field Field) FindInSet(targetList string) Expr

FindInSet use FIND_IN_SET(expr, ?)

func (Field) FindInSetCol

func (e Field) FindInSetCol(e2 Expr) Expr

FindInSetCol use FIND_IN_SET(expr1, expr2)

func (Field) FindInSetColWith

func (e Field) FindInSetColWith(e2 Expr) Expr

FindInSetColWith use FIND_IN_SET(expr2, expr1)

func (Field) FindInSetSubQuery

func (e Field) FindInSetSubQuery(subQuery *gorm.DB) Expr

FindInSetSubQuery FIND_IN_SET(column, (subQuery))

func (Field) FindInSetWith

func (field Field) FindInSetWith(target string) Expr

FindInSetWith use FIND_IN_SET(?, expr)

func (Field) Floor

func (field Field) Floor() Field

Floor se FLOOR(expr)

func (Field) FloorDiv

func (field Field) FloorDiv(value any) Field

FloorDiv use expr DIV ?

func (Field) FromDays

func (field Field) FromDays() Time

FromDays use FROM_DAYS(value)

func (Field) FromUnixTime

func (field Field) FromUnixTime(format ...string) String

FromUnixTime use FromUnixTime(unix_timestamp[, format])

func (Field) GroupConcat

func (e Field) GroupConcat() Expr

GroupConcat use GROUP_CONCAT(expr)

func (Field) Gt

func (field Field) Gt(value any) Expr

Gt use expr > ?

func (Field) GtCol

func (e Field) GtCol(e2 Expr) Expr

GtCol use expr1 > expr2

func (Field) GtSubQuery

func (e Field) GtSubQuery(subQuery *gorm.DB) Expr

GtSubQuery use expr1 > (subQuery)

func (Field) Gte

func (field Field) Gte(value any) Expr

Gte use expr >= ?

func (Field) GteCol

func (e Field) GteCol(e2 Expr) Expr

GteCol use expr1 >= expr2

func (Field) GteSubQuery

func (e Field) GteSubQuery(subQuery *gorm.DB) Expr

GteSubQuery use expr1 >= (subQuery)

func (Field) Hour

func (field Field) Hour() Int

Hour use HOUR(date) return the hour.

func (Field) IfNull

func (field Field) IfNull(value any) Expr

IfNull use IFNULL(expr,?)

func (Field) In

func (field Field) In(values ...any) Expr

In use expr IN (?)

func (Field) InSubQuery

func (e Field) InSubQuery(subQuery *gorm.DB) Expr

InSubQuery use expr1 IN (subQuery)

func (Field) IsNotNull

func (e Field) IsNotNull() Expr

IsNotNull use `expr IS NOT NULL`

func (Field) IsNull

func (e Field) IsNull() Expr

IsNull use expr IS NULL

func (Field) LTrim

func (field Field) LTrim(remStr string) String

LTrim use TRIM(LEADING ? FROM ?)

func (Field) LTrimSpace

func (field Field) LTrimSpace() String

LTrimSpace use LTRIM(?)

func (Field) LeftShift

func (field Field) LeftShift(value any) Field

LeftShift use expr<<?

func (Field) Length

func (e Field) Length() Int

Length use LENGTH(expr)

func (Field) Like

func (field Field) Like(value any) Expr

Like use expr LIKE ?

func (Field) Lt

func (field Field) Lt(value any) Expr

Lt use expr < ?

func (Field) LtCol

func (e Field) LtCol(e2 Expr) Expr

LtCol use expr1 < expr2

func (Field) LtSubQuery

func (e Field) LtSubQuery(subQuery *gorm.DB) Expr

LtSubQuery use expr1 < (subQuery)

func (Field) Lte

func (field Field) Lte(value any) Expr

Lte use expr <= ?

func (Field) LteCol

func (e Field) LteCol(e2 Expr) Expr

LteCol use expr1 <= expr2

func (Field) LteSubQuery

func (e Field) LteSubQuery(subQuery *gorm.DB) Expr

LteSubQuery use expr1 <= (subQuery)

func (Field) Max

func (e Field) Max() Float64

Max use MAX(expr)

func (Field) MicroSecond

func (field Field) MicroSecond() Int

MicroSecond use MICROSECOND(date) return the microsecond.

func (Field) Min

func (e Field) Min() Float64

Min use MIN(expr)

func (Field) Minute

func (field Field) Minute() Int

Minute use MINUTE(date) return the minute.

func (Field) Mod

func (field Field) Mod(value any) Field

Mod use expr%?

func (Field) Month

func (field Field) Month() Int

Month use MONTH(date) return the month.

func (Field) MonthName

func (field Field) MonthName() String

MonthName use MONTHNAME(date) return the name of the month of the year.

func (Field) Mul

func (field Field) Mul(value any) Field

Mul use expr*?

func (Field) MulCol

func (e Field) MulCol(col Expr) Field

MulCol use (expr1) * (expr2)

func (Field) Neq

func (field Field) Neq(value any) Expr

Neq use expr <> ?

func (Field) NeqCol

func (e Field) NeqCol(e2 Expr) Expr

NeqCol use expr1 <> expr2

func (Field) NeqSubQuery

func (e Field) NeqSubQuery(subQuery *gorm.DB) Expr

NeqSubQuery use expr1 <> (subQuery)

func (Field) NotBetween

func (field Field) NotBetween(left any, right any) Expr

NotBetween use NOT (expr BETWEEN ? AND ?)

func (Field) NotIn

func (field Field) NotIn(values ...any) Expr

NotIn use expr NOT IN (?)

func (Field) NotInSubQuery

func (e Field) NotInSubQuery(subQuery *gorm.DB) Expr

NotInSubQuery use expr1 NOT IN (subQuery)

func (Field) NotLike

func (field Field) NotLike(value any) Expr

NotLike use expr NOT LIKE ?

func (Field) NotRegxp

func (field Field) NotRegxp(value string) Expr

NotRegxp use NOT expr REGEXP ?

func (Field) NullIf added in v0.0.10

func (field Field) NullIf(value any) Expr

IfNull use NULLIF(expr,?)

func (Field) RTrim

func (field Field) RTrim(remStr string) String

RTrim use TRIM(TRAILING ? FROM ?)

func (Field) RTrimSpace

func (field Field) RTrimSpace() String

RTrimSpace use RTRIM(?)

func (Field) RawExpr

func (e Field) RawExpr() any

func (Field) Regexp

func (field Field) Regexp(value any) Expr

Regexp use expr REGEXP ?

func (Field) Replace

func (field Field) Replace(from, to string) String

Replace use REPLACE(expr,?,?)

func (Field) RightShift

func (field Field) RightShift(value any) Field

RightShift use expr>>?

func (Field) Round

func (field Field) Round(decimals int) Field

Round use ROUND(expr, ?)

func (Field) Second

func (field Field) Second() Int

Second use SECOND(date) return the second.

func (Field) SetCol

func (e Field) SetCol(e2 Expr) AssignExpr

SetCol expr1=expr2

func (Field) SetExpr

func (e Field) SetExpr() any

func (Field) SetSubQuery

func (e Field) SetSubQuery(subQuery *gorm.DB) AssignExpr

SetSubQuery set with subQuery

func (Field) Sub

func (field Field) Sub(value any) Field

Sub use below value type:

time.Duration: use DATE_SUB(expr, INTERVAL ? MICROSECOND)
other: use expr-?

func (Field) SubCol

func (e Field) SubCol(col Expr) Field

SubCol use expr1 - expr2

func (Field) SubstringIndex

func (field Field) SubstringIndex(delim string, count int) String

SubstringIndex use SUBSTRING_INDEX(expr,?,?) https://dev.mysql.com/doc/refman/8.0/en/functions.html#function_substring-index

func (Field) Sum

func (field Field) Sum() Field

Sum use SUM(expr)

func (Field) Trim

func (field Field) Trim(remStr string) String

Trim use TRIM(BOTH ? FROM ?)

func (Field) TrimSpace

func (field Field) TrimSpace() String

TrimSpace use TRIM(?)

func (Field) UnixTimestamp

func (field Field) UnixTimestamp() Int64

UnixTimestamp use UnixTimestamp(date)

func (Field) Value

func (field Field) Value(value any) AssignExpr

Value set value

func (Field) ValueAny

func (e Field) ValueAny(value any) AssignExpr

ValueAny set any value.

func (Field) ValueNull

func (e Field) ValueNull() AssignExpr

ValueNull set value NULL

func (Field) ValueSubQuery added in v0.0.11

func (e Field) ValueSubQuery(subQuery *gorm.DB) AssignExpr

ValueSubQuery set with subQuery same as SetSubQuery.

func (Field) WithTable

func (e Field) WithTable(table string) Expr

func (Field) Year

func (field Field) Year() Int

Year use YEAR(date) return the year.

type Float

type Float[T constraints.Float | ~string] Field

Float type field

func NewFloat

func NewFloat[T constraints.Float | ~string](table, column string, opts ...Option) Float[T]

NewFloat new float field.

func (Float[T]) Add

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

Add use expr+?

func (Float[T]) AddCol

func (e Float[T]) AddCol(col Expr) Float[T]

AddCol use expr1 + expr2

func (Float[T]) Between

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

Between use expr BETWEEN ? AND ?

func (Float[T]) Div

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

Div use expr/?

func (Float[T]) DivCol

func (e Float[T]) DivCol(col Expr) Float[T]

DivCol use (expr1) / (expr2)

func (Float[T]) Eq

func (field Float[T]) Eq(value T) Expr

Eq equal to, use expr = ?

func (Float[T]) FindInSet

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

FindInSet use FIND_IN_SET(expr, ?)

func (Float[T]) Floor

func (field Float[T]) Floor() Int

Floor se FLOOR(expr)

func (Float[T]) FloorDiv

func (field Float[T]) FloorDiv(value T) Int

FloorDiv use expr DIV ?

func (Float[T]) Gt

func (field Float[T]) Gt(value T) Expr

Gt greater than, use expr > ?

func (Float[T]) Gte

func (field Float[T]) Gte(value T) Expr

Gte greater or equal to, use expr >= ?

func (Float[T]) IfNull

func (field Float[T]) IfNull(value T) Expr

IfNull use IFNULL(expr,?)

func (Float[T]) In

func (field Float[T]) In(values ...T) Expr

In use expr IN (?)

func (Float[T]) InAny

func (field Float[T]) InAny(value any) Expr

InAny use expr IN (?) value must be a array/slice

func (Float[T]) IntoField

func (field Float[T]) IntoField() Field

IntoField convert into Field. then use Field abilities.

func (Float[T]) Like

func (field Float[T]) Like(value T) Expr

Like use expr LIKE ?

func (Float[T]) Lt

func (field Float[T]) Lt(value T) Expr

Lt less than, use expr < ?

func (Float[T]) Lte

func (field Float[T]) Lte(value T) Expr

Lte less or equal to, use expr <= ?

func (Float[T]) Mul

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

Mul use expr*?

func (Float[T]) MulCol

func (e Float[T]) MulCol(col Expr) Float[T]

MulCol use (expr1) * (expr2)

func (Float[T]) Neq

func (field Float[T]) Neq(value T) Expr

Neq not equal to, use expr <> ?

func (Float[T]) NotBetween

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

NotBetween use NOT (expr BETWEEN ? AND ?).

func (Float[T]) NotIn

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

NotIn use expr NOT IN (?)

func (Float[T]) NotInAny

func (field Float[T]) NotInAny(value any) Expr

NotInAny use expr NOT IN (?) value must be a array/slice

func (Float[T]) NotLike

func (field Float[T]) NotLike(value T) Expr

NotLike use expr NOT LIKE ?

func (Float[T]) NullIf added in v0.0.10

func (field Float[T]) NullIf(value T) Expr

NullIf use NULLIF(expr,?)

func (Float[T]) Round

func (field Float[T]) Round(decimals int) Float[T]

Round use ROUND(expr, ?)

func (Float[T]) Sub

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

Sub use expr-?

func (Float[T]) SubCol

func (e Float[T]) SubCol(col Expr) Float[T]

SubCol use expr1 - expr2

func (Float[T]) Sum

func (field Float[T]) Sum() Float[T]

Sum use SUM(expr)

func (Float[T]) Value

func (field Float[T]) Value(value T) AssignExpr

Value set value

func (Float[T]) ValuePointer

func (field Float[T]) ValuePointer(value *T) AssignExpr

Value set value use pointer

func (Float[T]) ValueZero

func (field Float[T]) ValueZero() AssignExpr

ValueZero set value zero

type Float32

type Float32 = Float[float32]

func NewFloat32

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

NewFloat32 new float32 field

type Float64

type Float64 = Float[float64]

func NewFloat64

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

NewFloat64 new float64 field

type From

type From struct {
	Alias    string
	SubQuery *gorm.DB
}

From hold subQuery

type Int

type Int = Integer[int]

func NewInt

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

NewField new int field

type Int16

type Int16 = Integer[int16]

func NewInt16

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

NewField new int16 field

type Int32

type Int32 = Integer[int32]

func NewInt32

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

NewField new int32 field

type Int64

type Int64 = Integer[int64]

func NewInt64

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

NewField new int64 field

func UnixTimestamp

func UnixTimestamp(date ...string) Int64

UnixTimestamp use UNIX_TIMESTAMP([date])

type Int8

type Int8 = Integer[int8]

func NewInt8

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

NewField new int8 field

type Integer

type Integer[T constraints.Integer] Field

Integer type field

func NewInteger

func NewInteger[T constraints.Integer](table, column string, opts ...Option) Integer[T]

NewInt new Integer

func (Integer[T]) Add

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

Add use expr+?

func (Integer[T]) AddCol

func (e Integer[T]) AddCol(col Expr) Integer[T]

AddCol use expr1 + expr2

func (Integer[T]) Between

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

Between use expr BETWEEN ? AND ?

func (Integer[T]) BitAnd

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

BitAnd use expr expr&?

func (Integer[T]) BitFlip

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

BitFlip use expr ~expr

func (Integer[T]) BitOr

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

BitOr use expr expr|?

func (Integer[T]) BitXor

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

BitXor use expr expr^?

func (Integer[T]) Div

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

Div use expr/?

func (Integer[T]) DivCol

func (e Integer[T]) DivCol(col Expr) Integer[T]

DivCol use (expr1) / (expr2)

func (Integer[T]) Eq

func (field Integer[T]) Eq(value T) Expr

Eq equal to, use expr = ?

func (Integer[T]) FindInSet

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

FindInSet equal to FIND_IN_SET(expr, ?)

func (Integer[T]) FloorDiv

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

FloorDiv use expr DIV ?

func (Integer[T]) FromDays

func (field Integer[T]) FromDays() Time

FromDays use FROM_DAYS(value)

func (Integer[T]) FromUnixTime

func (field Integer[T]) FromUnixTime(format ...string) String

FromUnixTime use FromUnixTime(unix_timestamp[, format])

func (Integer[T]) Gt

func (field Integer[T]) Gt(value T) Expr

Gt greater than, use expr > ?

func (Integer[T]) Gte

func (field Integer[T]) Gte(value T) Expr

Gte greater or equal to, use expr >= ?

func (Integer[T]) IfNull

func (field Integer[T]) IfNull(value T) Expr

IfNull use IFNULL(expr,?)

func (Integer[T]) In

func (field Integer[T]) In(values ...T) Expr

In use expr IN (?)

func (Integer[T]) InAny

func (field Integer[T]) InAny(value any) Expr

InAny use expr IN (?) value must be a array/slice

func (Integer[T]) IntoField

func (field Integer[T]) IntoField() Field

IntoField convert into Field. then use Field abilities.

func (Integer[T]) LeftShift

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

LeftShift use expr<<?

func (Integer[T]) Like

func (field Integer[T]) Like(value T) Expr

Like use expr LIKE ?

func (Integer[T]) Lt

func (field Integer[T]) Lt(value T) Expr

Lt less than, use expr < ?

func (Integer[T]) Lte

func (field Integer[T]) Lte(value T) Expr

Lte less or equal to, use expr <= ?

func (Integer[T]) Mod

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

Mod use expr%?

func (Integer[T]) Mul

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

Mul use expr*?

func (Integer[T]) MulCol

func (e Integer[T]) MulCol(col Expr) Integer[T]

MulCol use (expr1) * (expr2)

func (Integer[T]) Neq

func (field Integer[T]) Neq(value T) Expr

Neq not equal to, use expr <> ?

func (Integer[T]) NotBetween

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

NotBetween use NOT (expr BETWEEN ? AND ?)

func (Integer[T]) NotIn

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

NotIn use expr NOT IN (?)

func (Integer[T]) NotInAny

func (field Integer[T]) NotInAny(value any) Expr

NotInAny use expr NOT IN (?) value must be a array/slice

func (Integer[T]) NotLike

func (field Integer[T]) NotLike(value T) Expr

NotLike use expr NOT LIKE ?

func (Integer[T]) NullIf added in v0.0.10

func (field Integer[T]) NullIf(value T) Expr

use use NULLIF(expr,?)

func (Integer[T]) RightShift

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

RightShift use expr>>?

func (Integer[T]) Round

func (field Integer[T]) Round(value int) Integer[T]

Round use ROUND(expr, ?)

func (Integer[T]) Sub

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

Add use expr-?

func (Integer[T]) SubCol

func (e Integer[T]) SubCol(col Expr) Integer[T]

SubCol use expr1 - expr2

func (Integer[T]) Sum

func (field Integer[T]) Sum() Integer[T]

Sum use SUM(expr)

func (Integer[T]) Value

func (field Integer[T]) Value(value T) AssignExpr

Value set value

func (Integer[T]) ValuePointer

func (field Integer[T]) ValuePointer(value *T) AssignExpr

Value set value use pointer

func (Integer[T]) ValueZero

func (field Integer[T]) ValueZero() AssignExpr

ValueZero set value zero

type JoinTable added in v0.0.6

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

func NewJoinTable added in v0.0.6

func NewJoinTable(table schema.Tabler, alias string) *JoinTable

NewJoinTable new join table as alias

func NewJoinTableSubQuery added in v0.0.7

func NewJoinTableSubQuery(subQuery *gorm.DB, alias string) *JoinTable

NewJoinTableSubQuery new join table sub query as alias

func (*JoinTable) TableName added in v0.0.6

func (jt *JoinTable) TableName() string

TableName implement schema.Tabler

type JoinTableExpr added in v0.0.6

type JoinTableExpr struct {
	clause.Join
	TableExpr clause.Expression
}

JoinTableExpr join clause with table expression(sub query...)

func (JoinTableExpr) Build added in v0.0.6

func (join JoinTableExpr) Build(builder clause.Builder)

type Option

type Option func(clause.Column) clause.Column

Option field option

type Raw

type Raw = Field

func NewRaw

func NewRaw(sql string, vars ...any) Raw

NewRaw new raw

type SetExpr

type SetExpr = AssignExpr

type String

type String Field

String string type field

func FromUnixTime

func FromUnixTime(date int64, format ...string) String

FromUnixTime use FROM_UNIXTIME(unix_timestamp[,format])

func NewString

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

NewString new string field.

func (String) AddCol

func (field String) AddCol(col Expr) String

AddCol use expr1 + expr2

func (String) Between

func (field String) Between(left, right string) Expr

Between use expr BETWEEN ? AND ?

func (String) Concat

func (field String) Concat(before, after string) String

Concat use CONCAT(?,?,?)

func (String) ConcatCol

func (field String) ConcatCol(cols ...Expr) String

ConcatCol use CONCAT(expr1,exp2...exprN)

func (String) ConcatWsCol added in v0.0.10

func (field String) ConcatWsCol(separator Expr, cols ...Expr) String

ConcatWsCol use CONCAT_WS(separator,expr1,expr2,...exprN)

func (String) DivCol

func (field String) DivCol(col Expr) String

DivCol use (expr1) / (expr2)

func (String) Eq

func (field String) Eq(value string) Expr

Eq equal to, use expr = ?

func (String) FindInSet

func (field String) FindInSet(targetList string) Expr

FindInSet equal to FIND_IN_SET(expr, ?)

func (String) FindInSetWith

func (field String) FindInSetWith(target string) Expr

FindInSetWith equal to FIND_IN_SET(?, expr)

func (String) FuzzyLike

func (field String) FuzzyLike(value string) Expr

FuzzyLike use expr LIKE ?, ? contain prefix % and suffix % e.g. expr LIKE %value%

func (String) Gt

func (field String) Gt(value string) Expr

Gt greater than, use expr > ?

func (String) Gte

func (field String) Gte(value string) Expr

Gte greater or equal to, use expr >= ?

func (String) Hidden

func (field String) Hidden(left, right int, pad string) String

Hidden hidden field content. left > 0 && right > 0 -- CONCAT(LEFT(expr,left),pad,RIGHT(expr,right)) left > 0 && right <= 0 -- CONCAT(LEFT(expr,left),pad) right > 0 && left <= 0 -- CONCAT(pad,RIGHT(expr,right))

func (String) HiddenPrefix

func (field String) HiddenPrefix(right int, pad string) String

HiddenPrefix use CONCAT(pad,RIGHT(expr,right))

func (String) HiddenSuffix

func (field String) HiddenSuffix(left int, pad string) String

HiddenSuffix use CONCAT(LEFT(expr,left),pad)

func (String) IfNull

func (field String) IfNull(value string) Expr

IfNull use IFNULL(expr,?)

func (String) In

func (field String) In(values ...string) Expr

In use expr IN (?)

func (String) InAny

func (field String) InAny(value any) Expr

InAny use expr IN (?) value must be a array/slice

func (String) IntoField

func (field String) IntoField() Field

IntoField convert into Field. then use Field abilities.

func (String) LTrim

func (field String) LTrim(remStr string) String

LTrim use TRIM(LEADING ? FROM ?)

func (String) LTrimSpace

func (field String) LTrimSpace() String

LTrimSpace use LTRIM(?)

func (String) LeftLike

func (field String) LeftLike(value string) Expr

LeftLike use expr LIKE ?, ? contain suffix %. e.g. expr LIKE value%

func (String) Like

func (field String) Like(value string) Expr

Like use expr LIKE ?

func (String) Lt

func (field String) Lt(value string) Expr

Lt less than, use expr < ?

func (String) Lte

func (field String) Lte(value string) Expr

Lte less or equal to, use expr <= ?

func (String) MulCol

func (field String) MulCol(col Expr) String

MulCol use (expr1) * (expr2)

func (String) Neq

func (field String) Neq(value string) Expr

Neq not equal to, use expr <> ?

func (String) NotBetween

func (field String) NotBetween(left, right string) Expr

NotBetween use NOT (expr BETWEEN ? AND ?)

func (String) NotIn

func (field String) NotIn(values ...string) Expr

NotIn use expr NOT IN (?)

func (String) NotInAny

func (field String) NotInAny(value any) Expr

NotInAny use expr NOT IN (?) value must be a array/slice

func (String) NotLike

func (field String) NotLike(value string) Expr

NotLike use expr NOT LIKE ?

func (String) NotRegxp

func (field String) NotRegxp(value string) Expr

NotRegxp use NOT expr REGEXP ?

func (String) NullIf added in v0.0.10

func (field String) NullIf(value string) Expr

NullIf use NullIf(expr,?)

func (String) RTrim

func (field String) RTrim(remStr string) String

RTrim use TRIM(TRAILING ? FROM ?)

func (String) RTrimSpace

func (field String) RTrimSpace() String

RTrimSpace use RTRIM(?)

func (String) Regexp

func (field String) Regexp(value string) Expr

Regexp use expr REGEXP ?

func (String) Replace

func (field String) Replace(from, to string) String

Replace use REPLACE(expr,?,?)

func (String) SubCol

func (field String) SubCol(col Expr) String

SubCol use expr1 - expr2

func (String) SubstringIndex

func (field String) SubstringIndex(delim string, count int) String

SubstringIndex use SUBSTRING_INDEX(expr,?,?) https://dev.mysql.com/doc/refman/8.0/en/functions.html#function_substring-index

func (String) Trim

func (field String) Trim(remStr string) String

Trim use TRIM(BOTH ? FROM ?)

func (String) TrimSpace

func (field String) TrimSpace() String

TrimSpace use TRIM(?)

func (String) Value

func (field String) Value(value string) AssignExpr

Value set value

func (String) ValuePointer

func (field String) ValuePointer(value *string) AssignExpr

Value set value use pointer

func (String) ValueZero

func (field String) ValueZero() AssignExpr

ValueZero set value zero

type Table added in v0.0.5

type Table string

func (Table) TableName added in v0.0.5

func (t Table) TableName() string

TableName implement schema.Tabler interface

type Time

type Time Field

Time time type field

func CurDate

func CurDate() Time

CurDate return result of CURDATE()

func CurTime

func CurTime() Time

CurTime return result of CURTIME()

func FromDays

func FromDays(value int) Time

FromDays equal to FROM_DAYS(value)

func NewTime

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

NewTime bew time field

func Now

func Now() Time

Now return result of NOW()

func (Time) Add

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

Add use DATE_ADD(date, INTERVAL ? MICROSECOND)

func (Time) AddCol

func (e Time) AddCol(col Expr) Time

AddCol use expr1 + expr2

func (Time) Between

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

Between use expr BETWEEN ? AND ?

func (Time) Date

func (field Time) Date() Time

Date use DATE(expr) return the date.

func (Time) DateDiff

func (field Time) DateDiff(expr2 time.Time) Int

DateDiff use DATEDIFF(expr1, expr2)

func (Time) DateFormat

func (field Time) DateFormat(format string) String

DateFormat use DATE_FORMAT(date,format)

func (Time) Day

func (field Time) Day() Int

Day use DAY(date) return the day.

func (Time) DayName

func (field Time) DayName() String

DayName use DAYNAME(date) return the name of the day of the week.

func (Time) DayOfMonth

func (field Time) DayOfMonth() Int

DayOfMonth use DAYOFMONTH(date)

func (Time) DayOfWeek

func (field Time) DayOfWeek() Int

DayOfWeek use DAYOFWEEK(date)

func (Time) DayOfYear

func (field Time) DayOfYear() Int

DayOfYear use DAYOFYEAR(date)

func (Time) DivCol

func (e Time) DivCol(col Expr) Time

DivCol use (expr1) / (expr2)

func (Time) Eq

func (field Time) Eq(value time.Time) Expr

Eq equal to, use expr = ?

func (Time) FindInSet

func (field Time) FindInSet(targetList string) Expr

FindInSet use FIND_IN_SET(expr, ?)

func (Time) Gt

func (field Time) Gt(value time.Time) Expr

Gt greater than, use expr > ?

func (Time) Gte

func (field Time) Gte(value time.Time) Expr

Gte greater or equal to, use expr >= ?

func (Time) Hour

func (field Time) Hour() Int

Hour use HOUR(date) return the hour.

func (Time) IfNull

func (field Time) IfNull(value time.Time) Expr

IfNull use IFNULL(expr,?)

func (Time) In

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

In use expr IN (?)

func (Time) InAny

func (field Time) InAny(value any) Expr

InAny use expr IN (?) value must be a array/slice

func (Time) Lt

func (field Time) Lt(value time.Time) Expr

Lt less than, use expr < ?

func (Time) Lte

func (field Time) Lte(value time.Time) Expr

Lte less or equal to, use expr <= ?

func (Time) MicroSecond

func (field Time) MicroSecond() Int

MicroSecond use MICROSECOND(date) return the microsecond.

func (Time) Minute

func (field Time) Minute() Int

Minute use MINUTE(date) return the minute.

func (Time) Month

func (field Time) Month() Int

Month use MONTH(date) return the month.

func (Time) MonthName

func (field Time) MonthName() String

MonthName use MONTHNAME(date) return the name of the month of the year.

func (Time) MulCol

func (e Time) MulCol(col Expr) Time

MulCol use (expr1) * (expr2)

func (Time) Neq

func (field Time) Neq(value time.Time) Expr

Neq not equal to, use expr <> ?

func (Time) NotBetween

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

NotBetween use NOT (expr BETWEEN ? AND ?)

func (Time) NotIn

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

NotIn use expr NOT IN (?)

func (Time) NotInAny

func (field Time) NotInAny(value any) Expr

NotInAny use expr NOT IN (?) value must be a array/slice

func (Time) NullIf added in v0.0.10

func (field Time) NullIf(value time.Time) Expr

NullIf use NullIf(expr,?)

func (Time) Second

func (field Time) Second() Int

Second use SECOND(date) return the second.

func (Time) Sub

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

Sub use DATE_SUB(date, INTERVAL ? MICROSECOND)

func (Time) SubCol

func (e Time) SubCol(col Expr) Time

SubCol use expr1 - expr2

func (Time) Sum

func (field Time) Sum() Time

Sum use SUM(expr)

func (Time) UnixTimestamp

func (field Time) UnixTimestamp() Int64

UnixTimestamp use UnixTimestamp(date)

func (Time) Value

func (field Time) Value(value time.Time) AssignExpr

Value set value

func (Time) ValuePointer

func (field Time) ValuePointer(value *time.Time) AssignExpr

ValuePointer set value use pointer

func (Time) ValueZero

func (field Time) ValueZero() AssignExpr

ValueZero set value zero

func (Time) Year

func (field Time) Year() Int

Year use YEAR(date) return the year.

type Uint

type Uint = Integer[uint]

func NewUint

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

NewField new uint field

type Uint16

type Uint16 = Integer[uint16]

func NewUint16

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

NewField new uint16 field

type Uint32

type Uint32 = Integer[uint32]

func NewUint32

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

NewField new uint32 field

type Uint64

type Uint64 = Integer[uint64]

func NewUint64

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

NewField new uint64 field

type Uint8

type Uint8 = Integer[uint8]

func NewUint8

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

NewField new uint8 field

Jump to

Keyboard shortcuts

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