Documentation
¶
Index ¶
- Constants
- func FromQuery[T any](subQuery contracts.QueryBuilder[T], as string) contracts.QueryBuilder[T]
- func FromSub[T any](callback contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
- func JoinStringerArray(arr []fmt.Stringer, sep string) (result string)
- func JoinSubStringerArray(arr []fmt.Stringer, sep string) (result string)
- func New[T any](table string) contracts.QueryBuilder[T]
- type Builder
- func (builder *Builder[T]) AddSelect(fields ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) AddSelectSub(provider contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Bind(executor contracts.QueryExecutor[T]) contracts.QueryBuilder[T]
- func (builder *Builder[T]) CreateSql(value contracts.Fields, insertType2 ...contracts.InsertType) (sql string, bindings []any)
- func (builder *Builder[T]) DeleteSql() (sql string, bindings []any)
- func (builder *Builder[T]) Distinct() contracts.QueryBuilder[T]
- func (builder *Builder[T]) From(table string, as ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) FromMany(tables ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) FromSub(provider contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) FullJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) FullOutJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) GetBindings() (results []any)
- func (builder *Builder[T]) GetTableName() string
- func (builder *Builder[T]) GetWith() []contracts.RelationType
- func (builder *Builder[T]) GroupBy(columns ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Having(field string, args ...any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) InRandomOrder(orderFunc ...contracts.OrderType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) InsertIgnoreSql(values []contracts.Fields) (sql string, bindings []any)
- func (builder *Builder[T]) InsertReplaceSql(values []contracts.Fields) (sql string, bindings []any)
- func (builder *Builder[T]) InsertSql(values []contracts.Fields, insertType2 ...contracts.InsertType) (sql string, bindings []any)
- func (builder *Builder[T]) Join(table string, first, condition, second string, joins ...contracts.JoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) JoinSub(provider contracts.QueryProvider[T], as, first, condition, second string, ...) contracts.QueryBuilder[T]
- func (builder *Builder[T]) LeftJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Limit(num int64) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Offset(offset int64) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrHaving(field string, args ...any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhere(field string, args ...any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereBetween(field string, args any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereExists(provider contracts.QueryProvider[T]) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereExistsRaw(raw string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereFunc(callback contracts.QueryFunc[T]) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereIn(field string, args any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereIsNull(field string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereNotBetween(field string, args any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereNotExists(provider contracts.QueryProvider[T]) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereNotIn(field string, args any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereNotNull(field string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrWhereRaw(raw string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrderBy(field string, columnOrderType ...contracts.OrderType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) OrderByDesc(field string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) RightJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Select(fields ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) SelectForUpdateSql() (string, []any)
- func (builder *Builder[T]) SelectSql() (string, []any)
- func (builder *Builder[T]) SelectSub(provider contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Skip(offset int64) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Take(num int64) contracts.QueryBuilder[T]
- func (builder *Builder[T]) ToSql() string
- func (builder *Builder[T]) Union(b contracts.QueryBuilder[T], unionType ...contracts.UnionJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) UnionAll(b contracts.QueryBuilder[T]) contracts.QueryBuilder[T]
- func (builder *Builder[T]) UnionAllByProvider(provider contracts.QueryProvider[T]) contracts.QueryBuilder[T]
- func (builder *Builder[T]) UnionByProvider(provider contracts.QueryProvider[T], unionType ...contracts.UnionJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) UpdateSql(value contracts.Fields) (sql string, bindings []any)
- func (builder *Builder[T]) When(condition bool, callback contracts.QueryCallback[T], ...) contracts.QueryBuilder[T]
- func (builder *Builder[T]) Where(field string, args ...any) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereBetween(field string, args any, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereExists(provider contracts.QueryProvider[T], where ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereExistsRaw(raw string, where ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereFields(fields contracts.Fields) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereFunc(callback contracts.QueryFunc[T], whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereIn(field string, args any, joinType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereIsNull(field string, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereNotBetween(field string, args any, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereNotExists(provider contracts.QueryProvider[T], where ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereNotIn(field string, args any, joinType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereNotNull(field string, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WhereRaw(raw string, whereTypes ...contracts.WhereJoinType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) With(relations ...contracts.RelationType) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WithAvg(field string, as ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WithCount(fields ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WithMax(field string, as ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WithMin(field string, as ...string) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WithPagination(perPage int64, current ...int64) contracts.QueryBuilder[T]
- func (builder *Builder[T]) WithSum(field string, as ...string) contracts.QueryBuilder[T]
- type Expression
- type GroupBy
- type Join
- type Joins
- type OrderBy
- type OrderByFields
- type ParamException
- type Unions
- type Where
- type Wheres
Constants ¶
View Source
const RandOrder contracts.OrderType = "RAND()"
View Source
const RandomOrder contracts.OrderType = "RANDOM()"
Variables ¶
This section is empty.
Functions ¶
func FromQuery ¶ added in v0.2.0
func FromQuery[T any](subQuery contracts.QueryBuilder[T], as string) contracts.QueryBuilder[T]
func FromSub ¶
func FromSub[T any](callback contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
func JoinSubStringerArray ¶
Types ¶
type Builder ¶
type Builder[T any] struct { contracts.QueryExecutor[T] Selects []string Withs []contracts.RelationType // contains filtered or unexported fields }
func NewBuilder ¶ added in v0.2.0
func (*Builder[T]) AddSelect ¶
func (builder *Builder[T]) AddSelect(fields ...string) contracts.QueryBuilder[T]
func (*Builder[T]) AddSelectSub ¶
func (builder *Builder[T]) AddSelectSub(provider contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
func (*Builder[T]) Bind ¶ added in v0.1.5
func (builder *Builder[T]) Bind(executor contracts.QueryExecutor[T]) contracts.QueryBuilder[T]
func (*Builder[T]) Distinct ¶
func (builder *Builder[T]) Distinct() contracts.QueryBuilder[T]
func (*Builder[T]) From ¶
func (builder *Builder[T]) From(table string, as ...string) contracts.QueryBuilder[T]
func (*Builder[T]) FromMany ¶
func (builder *Builder[T]) FromMany(tables ...string) contracts.QueryBuilder[T]
func (*Builder[T]) FromSub ¶
func (builder *Builder[T]) FromSub(provider contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
func (*Builder[T]) FullJoin ¶
func (builder *Builder[T]) FullJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
func (*Builder[T]) FullOutJoin ¶
func (builder *Builder[T]) FullOutJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
func (*Builder[T]) GetBindings ¶
func (*Builder[T]) GetTableName ¶ added in v0.5.2
func (*Builder[T]) GetWith ¶ added in v0.5.2
func (builder *Builder[T]) GetWith() []contracts.RelationType
func (*Builder[T]) GroupBy ¶
func (builder *Builder[T]) GroupBy(columns ...string) contracts.QueryBuilder[T]
func (*Builder[T]) Having ¶
func (builder *Builder[T]) Having(field string, args ...any) contracts.QueryBuilder[T]
func (*Builder[T]) InRandomOrder ¶ added in v0.1.11
func (builder *Builder[T]) InRandomOrder(orderFunc ...contracts.OrderType) contracts.QueryBuilder[T]
func (*Builder[T]) InsertIgnoreSql ¶
func (*Builder[T]) InsertReplaceSql ¶
func (*Builder[T]) JoinSub ¶
func (builder *Builder[T]) JoinSub(provider contracts.QueryProvider[T], as, first, condition, second string, joins ...contracts.JoinType) contracts.QueryBuilder[T]
func (*Builder[T]) LeftJoin ¶
func (builder *Builder[T]) LeftJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
func (*Builder[T]) Offset ¶
func (builder *Builder[T]) Offset(offset int64) contracts.QueryBuilder[T]
func (*Builder[T]) OrHaving ¶
func (builder *Builder[T]) OrHaving(field string, args ...any) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhere ¶
func (builder *Builder[T]) OrWhere(field string, args ...any) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereBetween ¶
func (builder *Builder[T]) OrWhereBetween(field string, args any) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereExists ¶
func (builder *Builder[T]) OrWhereExists(provider contracts.QueryProvider[T]) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereExistsRaw ¶ added in v0.5.2
func (builder *Builder[T]) OrWhereExistsRaw(raw string) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereFunc ¶
func (builder *Builder[T]) OrWhereFunc(callback contracts.QueryFunc[T]) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereIn ¶
func (builder *Builder[T]) OrWhereIn(field string, args any) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereIsNull ¶
func (builder *Builder[T]) OrWhereIsNull(field string) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereNotBetween ¶
func (builder *Builder[T]) OrWhereNotBetween(field string, args any) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereNotExists ¶
func (builder *Builder[T]) OrWhereNotExists(provider contracts.QueryProvider[T]) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereNotIn ¶
func (builder *Builder[T]) OrWhereNotIn(field string, args any) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereNotNull ¶
func (builder *Builder[T]) OrWhereNotNull(field string) contracts.QueryBuilder[T]
func (*Builder[T]) OrWhereRaw ¶ added in v0.5.2
func (builder *Builder[T]) OrWhereRaw(raw string) contracts.QueryBuilder[T]
func (*Builder[T]) OrderByDesc ¶
func (builder *Builder[T]) OrderByDesc(field string) contracts.QueryBuilder[T]
func (*Builder[T]) RightJoin ¶
func (builder *Builder[T]) RightJoin(table string, first, condition, second string) contracts.QueryBuilder[T]
func (*Builder[T]) Select ¶
func (builder *Builder[T]) Select(fields ...string) contracts.QueryBuilder[T]
func (*Builder[T]) SelectForUpdateSql ¶ added in v0.1.13
func (*Builder[T]) SelectSub ¶
func (builder *Builder[T]) SelectSub(provider contracts.QueryProvider[T], as string) contracts.QueryBuilder[T]
func (*Builder[T]) Union ¶
func (builder *Builder[T]) Union(b contracts.QueryBuilder[T], unionType ...contracts.UnionJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) UnionAll ¶
func (builder *Builder[T]) UnionAll(b contracts.QueryBuilder[T]) contracts.QueryBuilder[T]
func (*Builder[T]) UnionAllByProvider ¶
func (builder *Builder[T]) UnionAllByProvider(provider contracts.QueryProvider[T]) contracts.QueryBuilder[T]
func (*Builder[T]) UnionByProvider ¶
func (builder *Builder[T]) UnionByProvider(provider contracts.QueryProvider[T], unionType ...contracts.UnionJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) When ¶
func (builder *Builder[T]) When(condition bool, callback contracts.QueryCallback[T], elseCallback ...contracts.QueryCallback[T]) contracts.QueryBuilder[T]
func (*Builder[T]) Where ¶
func (builder *Builder[T]) Where(field string, args ...any) contracts.QueryBuilder[T]
func (*Builder[T]) WhereBetween ¶
func (builder *Builder[T]) WhereBetween(field string, args any, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
WhereBetween args 参数可以是整数、浮点数、字符串、any 等类型的数组,或者用` and `隔开的字符串,或者在源码中了解更多 https://github.com/goal-web/querybuilder/blob/78bcc832604bfcdb68579e3dd1441796a16994cf/builder.go#L74
func (*Builder[T]) WhereExists ¶
func (builder *Builder[T]) WhereExists(provider contracts.QueryProvider[T], where ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereExistsRaw ¶ added in v0.5.2
func (builder *Builder[T]) WhereExistsRaw(raw string, where ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereFields ¶ added in v0.1.4
func (builder *Builder[T]) WhereFields(fields contracts.Fields) contracts.QueryBuilder[T]
func (*Builder[T]) WhereFunc ¶
func (builder *Builder[T]) WhereFunc(callback contracts.QueryFunc[T], whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereIn ¶
func (builder *Builder[T]) WhereIn(field string, args any, joinType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
WhereIn args 参数可以是整数、浮点数、字符串、any 等类型的数组,或者用` and `隔开的字符串,或者在源码中了解更多 https://github.com/goal-web/querybuilder/blob/78bcc832604bfcdb68579e3dd1441796a16994cf/builder.go#L74
func (*Builder[T]) WhereIsNull ¶
func (builder *Builder[T]) WhereIsNull(field string, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereNotBetween ¶
func (builder *Builder[T]) WhereNotBetween(field string, args any, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereNotExists ¶
func (builder *Builder[T]) WhereNotExists(provider contracts.QueryProvider[T], where ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereNotIn ¶
func (builder *Builder[T]) WhereNotIn(field string, args any, joinType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereNotNull ¶
func (builder *Builder[T]) WhereNotNull(field string, whereType ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) WhereRaw ¶ added in v0.5.2
func (builder *Builder[T]) WhereRaw(raw string, whereTypes ...contracts.WhereJoinType) contracts.QueryBuilder[T]
func (*Builder[T]) With ¶ added in v0.5.2
func (builder *Builder[T]) With(relations ...contracts.RelationType) contracts.QueryBuilder[T]
func (*Builder[T]) WithAvg ¶ added in v0.1.2
func (builder *Builder[T]) WithAvg(field string, as ...string) contracts.QueryBuilder[T]
func (*Builder[T]) WithCount ¶ added in v0.1.2
func (builder *Builder[T]) WithCount(fields ...string) contracts.QueryBuilder[T]
func (*Builder[T]) WithMax ¶ added in v0.1.2
func (builder *Builder[T]) WithMax(field string, as ...string) contracts.QueryBuilder[T]
func (*Builder[T]) WithMin ¶ added in v0.1.2
func (builder *Builder[T]) WithMin(field string, as ...string) contracts.QueryBuilder[T]
func (*Builder[T]) WithPagination ¶
func (builder *Builder[T]) WithPagination(perPage int64, current ...int64) contracts.QueryBuilder[T]
type Expression ¶ added in v0.1.14
type Expression string
type OrderByFields ¶
type OrderByFields []OrderBy
func (OrderByFields) IsEmpty ¶
func (orderByFields OrderByFields) IsEmpty() bool
func (OrderByFields) String ¶
func (orderByFields OrderByFields) String() string
type ParamException ¶
type ParamException struct { Err error Arg any Condition string // contains filtered or unexported fields }
func (ParamException) Error ¶
func (p ParamException) Error() string
func (ParamException) GetPrevious ¶ added in v0.1.18
func (p ParamException) GetPrevious() contracts.Exception
type Unions ¶
type Unions[T any] map[contracts.UnionJoinType][]contracts.QueryBuilder[T]
Click to show internal directories.
Click to hide internal directories.