querybuilder

package module
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 5 Imported by: 5

README

Goal/QueryBuilder

Goal 的数据库查询构造器为创建和运行数据库查询提供了一个方便的接口。它可以用于支持大部分数据库操作,并与 Goal 支持的所有数据库系统完美运行。并且大量参考了 Laravel 的查询构造器设计,你几乎可以在这个库找到所有与 Laravel 对应的方法。

Goal 的查询构造器实现了类似 PDO 参数绑定的形式,来保护您的应用程序免受 SQL 注入攻击。因此不必清理因参数绑定而传入的字符串。查询构造器会返回你想要的 SQL 语句以及绑定参数。

运行数据库查询

根据条件从表中检索出数据

你可以使用 NewQuery 方法来开始查询。该方法为给定的表返回一个查询构造器实例,允许你在查询上链式调用更多的约束,最后使用 get 方法获取结果:

package querybuilder
import (
	"fmt"
)

func TestSimpleQueryBuilder() {
    query := NewQuery("users").
		Where("name", "qbhy").
        Where("age", ">", 18).
        Where("gender", "!=", 0).
        OrWhere("amount", ">=", 100).
        WhereIsNull("avatar")
	
    fmt.Println(query.ToSql())
    fmt.Println(query.GetBindings())
    // select * from users where name = ? and age > ? and gender != ? and avatar is null or amount >= ?
    // [qbhy 18 0 100]
}

你也可以通过 SelectSql 方法一次性获取你想要的参数。 例如:sql, bindings := NewQuery("users").Where("gender", 1).SelectSql()

插入语句

你可以通过 InsertSql 或者 CreateSql 很方便的生成插入语句。

package querybuilder

import (
	"fmt"
	"github.com/goal-web/contracts"
)

// TestInsertSql 批量插入数据
func TestInsertSql() {
	sql, bindings := NewQuery("users").InsertSql([]contracts.Fields{
		{"name": "qbhy", "age": 18, "money": 100000000000},
		{"name": "goal", "age": 18, "money": 10},
	})
	fmt.Println(sql)
	fmt.Println(bindings)
	// insert into users (name,age,money) values (?,?,?),(?,?,?)
	// [qbhy 18 100000000000 goal 18 10]
}
// TestCreateSql 插入单个数据
func TestCreateSql() {
	sql, bindings := NewQuery("users").CreateSql(contracts.Fields{
		"name": "qbhy", "age": 18, "money": 100000000000,
	})
	fmt.Println(sql)
	fmt.Println(bindings) 
	// insert into users (name,age,money) values (?,?,?) 
	//[qbhy 18 100000000000]
}
更新语句

你可以通过 UpdateSql 很方便的生成更新语句。

package querybuilder

import (
	"fmt"
	"github.com/goal-web/contracts"
)

func TestUpdateSql() {
	sql, bindings := NewQuery("users").Where("id", ">", 1).UpdateSql(contracts.Fields{
		"name": "qbhy", "age": 18, "money": 100000000000,
	})
	fmt.Println(sql)
	fmt.Println(bindings)
    // update users set money = ?,name = ?,age = ? where id > ?
    // [qbhy 18 100000000000 1]
}
删除语句

你可以通过 DeleteSql 很方便的生成删除语句。

package querybuilder

import (
	"fmt"
)

func TestDeleteSql() {
	sql, bindings := NewQuery("users").Where("id", ">", 1).DeleteSql()
	fmt.Println(sql)
	fmt.Println(bindings)
    // delete from users where id > ?
    // [1]
}

更多高级用法

支持 where嵌套、子查询、连表、连子查询等更多高级用法

package tests

import (
	"fmt"
	"github.com/goal-web/contracts"
	builder "github.com/goal-web/querybuilder"
	"github.com/stretchr/testify/assert"
	"github.com/xwb1989/sqlparser"
	"testing"
)

func TestSimpleQueryBuilder(t *testing.T) {
	query := builder.NewQuery("users")
	query.Where("name", "qbhy").
		Where("age", ">", 18).
		Where("gender", "!=", 0, contracts.Or).
		OrWhere("amount", ">=", 100).
		WhereIsNull("avatar")
	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())

	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

func TestJoinQueryBuilder(t *testing.T) {
	query := builder.NewQuery("users").
		Join("accounts", "accounts.user_id", "=", "users.id").
		JoinSub(func() contracts.QueryBuilder {
			return builder.NewQuery("users").
				Where("level", ">", 5)
		}, "vip_users", "vip_users.id", "=", "users.id").
		//WhereIn("gender", "1,2").
		WhereIn("gender", []int{1, 2})
	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())
	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

func TestFromSubQueryBuilder(t *testing.T) {
	query := builder.FromSub(func() contracts.QueryBuilder {
		return builder.NewQuery("users").
			Where("level", ">", 5)
	}, "vip_users").
		//WhereIn("gender", "1,2").
		WhereIn("gender", []int{1, 2})
	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())
	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

func TestDistinctQueryBuilder(t *testing.T) {
	query := builder.NewQuery("users").
		Distinct().
		Join("accounts", "accounts.user_id", "=", "users.id").
		Where("gender", "!=", 0, contracts.Or)
	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())
	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

func TestUpdateSql(t *testing.T) {
	sql, bindings := builder.NewQuery("users").Where("id", ">", 1).UpdateSql(contracts.Fields{
		"name": "qbhy", "age": 18, "money": 100000000000,
	})
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}
func TestSelectSub(t *testing.T) {
	sql, bindings := builder.NewQuery("users").Where("id", ">", 1).
		SelectSub(func() contracts.QueryBuilder {
			return builder.NewQuery("accounts").Where("accounts.id", "users.id").WithCount()
		}, "accounts_count").
		Join("accounts", "accounts.user_id", "=", "users.id").
		SelectSql()
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}
func TestWhereNotExists(t *testing.T) {
	sql, bindings := builder.NewQuery("users").
		Where("id", ">", 1).
		WhereNotExists(func() contracts.QueryBuilder {
			return builder.NewQuery("users").Select("id").Where("age", ">", 18)
		}).
		SelectSql()
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}
func TestCount(t *testing.T) {
	sql, bindings := builder.NewQuery("users").Where("id", ">", 1).WithCount("id").SelectSql()
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}
func TestDeleteSql(t *testing.T) {
	sql, bindings := builder.NewQuery("users").Where("id", ">", 1).DeleteSql()
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}
func TestInsertSql(t *testing.T) {
	sql, bindings := builder.NewQuery("users").InsertSql([]contracts.Fields{
		{"name": "qbhy", "age": 18, "money": 100000000000},
		{"name": "goal", "age": 18, "money": 10},
	})
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}
func TestInsertIgnoreSql(t *testing.T) {
	sql, bindings := builder.NewQuery("users").InsertIgnoreSql([]contracts.Fields{
		{"name": "qbhy", "age": 18, "money": 100000000000},
		{"name": "goal", "age": 18, "money": 10},
	})
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}
func TestInsertReplaceSql(t *testing.T) {
	sql, bindings := builder.NewQuery("users").InsertReplaceSql([]contracts.Fields{
		{"name": "qbhy", "age": 18, "money": 100000000000},
		{"name": "goal", "age": 18, "money": 10},
	})
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}

func TestCreateSql(t *testing.T) {
	sql, bindings := builder.NewQuery("users").CreateSql(contracts.Fields{
		"name": "qbhy", "age": 18, "money": 100000000000,
	})
	fmt.Println(sql)
	fmt.Println(bindings)
	_, err := sqlparser.Parse(sql)
	assert.Nil(t, err, err)
}

func TestBetweenQueryBuilder(t *testing.T) {
	query := builder.NewQuery("users").
		Join("accounts", "accounts.user_id", "=", "users.id").
		WhereFunc(func(b contracts.QueryBuilder) {
			// 高瘦
			b.WhereBetween("height", []int{180, 200}).
				WhereBetween("weight", []int{50, 60}).
				WhereIn("id", []int{1, 2, 3, 4, 5})
		}).OrWhereFunc(func(b contracts.QueryBuilder) {
		// 矮胖
		b.WhereBetween("height", []int{140, 160}).
			WhereBetween("weight", []int{70, 140}).
			WhereNotBetween("id", []int{1, 5})
	})
	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())
	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

func TestUnionQueryBuilder(t *testing.T) {
	query := builder.NewQuery("users").
		Join("accounts", "accounts.user_id", "=", "users.id").
		Where("gender", "!=", 0, contracts.Or).
		UnionByProvider(
			func() contracts.QueryBuilder {
				return builder.NewQuery("peoples").Where("id", 5)
			},
		).
		Union(
			builder.NewQuery("accounts"),
		).
		UnionAll(
			builder.NewQuery("members"),
		).
		UnionAll(
			builder.NewQuery("students"),
		)
	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())
	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

func TestComplexQueryBuilder(t *testing.T) {

	query := builder.NewQuery("users")
	query.
		FromSub(func() contracts.QueryBuilder {
			return builder.NewQuery("users").Where("amount", ">", 1000)
		}, "rich_users").
		Join("accounts", "users.id", "=", "accounts.user_id").
		WhereFunc(func(b contracts.QueryBuilder) {
			b.Where("name", "goal").
				Where("age", "<", "18").
				WhereIn("id", []int{1, 2})
		}).
		OrWhereFunc(func(b contracts.QueryBuilder) {
			b.Where("name", "qbhy").
				Where("age", ">", 18).
				WhereNotIn("id", []int{1, 2})
		}).
		OrWhereNotIn("id", []int{6, 7}).
		OrWhereNotNull("id").
		OrderByDesc("age").
		OrderBy("id").
		GroupBy("country")

	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())
	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

func TestGroupByQueryBuilder(t *testing.T) {

	query := builder.
		FromSub(func() contracts.QueryBuilder {
			return builder.NewQuery("users").Where("amount", ">", 1000)
		}, "rich_users").
		GroupBy("country").
		Having("count(rich_users.id)", "<", 1000).   // 人口少
		OrHaving("sum(rich_users.amount)", "<", 100) // 或者穷

	fmt.Println(query.ToSql())
	fmt.Println(query.GetBindings())
	_, err := sqlparser.Parse(query.ToSql())
	assert.Nil(t, err, err)
}

正如开头所说,你可以在这里找到几乎所有与 Laravel 对应的查询构造器方法,也可以在 测试文件 中找到更多用法

goal/query-builder
qbhy0715@qq.com

Documentation

Index

Constants

View Source
const RandOrder contracts.OrderType = "RAND()"
View Source
const RandomOrder contracts.OrderType = "RANDOM()"

Variables

This section is empty.

Functions

func FromSub

func FromSub(callback contracts.QueryProvider, as string) contracts.QueryBuilder

func JoinStringerArray

func JoinStringerArray(arr []fmt.Stringer, sep string) (result string)

func JoinSubStringerArray

func JoinSubStringerArray(arr []fmt.Stringer, sep string) (result string)

Types

type Builder

type Builder struct {
	contracts.QueryBuilder
	// contains filtered or unexported fields
}

func NewQuery

func NewQuery(table string) *Builder

func (*Builder) AddSelect

func (this *Builder) AddSelect(fields ...string) contracts.QueryBuilder

func (*Builder) AddSelectSub

func (this *Builder) AddSelectSub(provider contracts.QueryProvider, as string) contracts.QueryBuilder

func (*Builder) Avg

func (this *Builder) Avg(column string, as ...string) int64

func (*Builder) Bind added in v0.1.5

func (this *Builder) Bind(builder contracts.QueryBuilder) contracts.QueryBuilder

func (*Builder) Count

func (this *Builder) Count(columns ...string) int64

func (*Builder) Create

func (this *Builder) Create(fields contracts.Fields) interface{}

func (*Builder) CreateSql

func (this *Builder) CreateSql(value contracts.Fields, insertType2 ...contracts.InsertType) (sql string, bindings []interface{})

func (*Builder) Delete

func (this *Builder) Delete() int64

func (*Builder) DeleteSql

func (this *Builder) DeleteSql() (sql string, bindings []interface{})

func (*Builder) Distinct

func (this *Builder) Distinct() contracts.QueryBuilder

func (*Builder) Find

func (this *Builder) Find(key interface{}) interface{}

func (*Builder) First

func (this *Builder) First() interface{}

func (*Builder) FirstOr added in v0.1.2

func (this *Builder) FirstOr(provider contracts.InstanceProvider) interface{}

func (*Builder) FirstOrCreate added in v0.1.2

func (this *Builder) FirstOrCreate(values ...contracts.Fields) interface{}

func (*Builder) FirstOrFail added in v0.1.2

func (this *Builder) FirstOrFail() interface{}

func (*Builder) FirstWhere added in v0.1.2

func (this *Builder) FirstWhere(column string, args ...interface{}) interface{}

func (*Builder) From

func (this *Builder) From(table string, as ...string) contracts.QueryBuilder

func (*Builder) FromMany

func (this *Builder) FromMany(tables ...string) contracts.QueryBuilder

func (*Builder) FromSub

func (this *Builder) FromSub(provider contracts.QueryProvider, as string) contracts.QueryBuilder

func (*Builder) FullJoin

func (this *Builder) FullJoin(table string, first, condition, second string) contracts.QueryBuilder

func (*Builder) FullOutJoin

func (this *Builder) FullOutJoin(table string, first, condition, second string) contracts.QueryBuilder

func (*Builder) Get

func (this *Builder) Get() contracts.Collection

func (*Builder) GetBindings

func (this *Builder) GetBindings() (results []interface{})

func (*Builder) GroupBy

func (this *Builder) GroupBy(columns ...string) contracts.QueryBuilder

func (*Builder) Having

func (this *Builder) Having(field string, args ...interface{}) contracts.QueryBuilder

func (*Builder) InRandomOrder added in v0.1.11

func (this *Builder) InRandomOrder() contracts.QueryBuilder

func (*Builder) Insert

func (this *Builder) Insert(values ...contracts.Fields) bool

func (*Builder) InsertGetId added in v0.1.2

func (this *Builder) InsertGetId(values ...contracts.Fields) int64

func (*Builder) InsertIgnoreSql

func (this *Builder) InsertIgnoreSql(values []contracts.Fields) (sql string, bindings []interface{})

func (*Builder) InsertOrIgnore added in v0.1.2

func (this *Builder) InsertOrIgnore(values ...contracts.Fields) int64

func (*Builder) InsertOrReplace added in v0.1.2

func (this *Builder) InsertOrReplace(values ...contracts.Fields) int64

func (*Builder) InsertReplaceSql

func (this *Builder) InsertReplaceSql(values []contracts.Fields) (sql string, bindings []interface{})

func (*Builder) InsertSql

func (this *Builder) InsertSql(values []contracts.Fields, insertType2 ...contracts.InsertType) (sql string, bindings []interface{})

func (*Builder) Join

func (this *Builder) Join(table string, first, condition, second string, joins ...contracts.JoinType) contracts.QueryBuilder

func (*Builder) JoinSub

func (this *Builder) JoinSub(provider contracts.QueryProvider, as, first, condition, second string, joins ...contracts.JoinType) contracts.QueryBuilder

func (*Builder) LeftJoin

func (this *Builder) LeftJoin(table string, first, condition, second string) contracts.QueryBuilder

func (*Builder) Limit

func (this *Builder) Limit(num int64) contracts.QueryBuilder

func (*Builder) Max

func (this *Builder) Max(column string, as ...string) int64

func (*Builder) Min

func (this *Builder) Min(column string, as ...string) int64

func (*Builder) Offset

func (this *Builder) Offset(offset int64) contracts.QueryBuilder

func (*Builder) OrHaving

func (this *Builder) OrHaving(field string, args ...interface{}) contracts.QueryBuilder

func (*Builder) OrWhere

func (this *Builder) OrWhere(field string, args ...interface{}) contracts.QueryBuilder

func (*Builder) OrWhereBetween

func (this *Builder) OrWhereBetween(field string, args interface{}) contracts.QueryBuilder

func (*Builder) OrWhereExists

func (this *Builder) OrWhereExists(provider contracts.QueryProvider) contracts.QueryBuilder

func (*Builder) OrWhereFunc

func (this *Builder) OrWhereFunc(callback contracts.QueryFunc) contracts.QueryBuilder

func (*Builder) OrWhereIn

func (this *Builder) OrWhereIn(field string, args interface{}) contracts.QueryBuilder

func (*Builder) OrWhereIsNull

func (this *Builder) OrWhereIsNull(field string) contracts.QueryBuilder

func (*Builder) OrWhereNotBetween

func (this *Builder) OrWhereNotBetween(field string, args interface{}) contracts.QueryBuilder

func (*Builder) OrWhereNotExists

func (this *Builder) OrWhereNotExists(provider contracts.QueryProvider) contracts.QueryBuilder

func (*Builder) OrWhereNotIn

func (this *Builder) OrWhereNotIn(field string, args interface{}) contracts.QueryBuilder

func (*Builder) OrWhereNotNull

func (this *Builder) OrWhereNotNull(field string) contracts.QueryBuilder

func (*Builder) OrderBy

func (this *Builder) OrderBy(field string, columnOrderType ...contracts.OrderType) contracts.QueryBuilder

func (*Builder) OrderByDesc

func (this *Builder) OrderByDesc(field string) contracts.QueryBuilder

func (*Builder) Paginate

func (this *Builder) Paginate(perPage int64, current ...int64) (contracts.Collection, int64)

func (*Builder) RightJoin

func (this *Builder) RightJoin(table string, first, condition, second string) contracts.QueryBuilder

func (*Builder) Select

func (this *Builder) Select(fields ...string) contracts.QueryBuilder

func (*Builder) SelectSql

func (this *Builder) SelectSql() (string, []interface{})

func (*Builder) SelectSub

func (this *Builder) SelectSub(provider contracts.QueryProvider, as string) contracts.QueryBuilder

func (*Builder) SetExecutor added in v0.1.8

func (this *Builder) SetExecutor(executor contracts.SqlExecutor) contracts.QueryBuilder

func (*Builder) SimplePaginate

func (this *Builder) SimplePaginate(perPage int64, current ...int64) contracts.Collection

func (*Builder) Skip

func (this *Builder) Skip(offset int64) contracts.QueryBuilder

func (*Builder) Sum

func (this *Builder) Sum(column string, as ...string) int64

func (*Builder) Take

func (this *Builder) Take(num int64) contracts.QueryBuilder

func (*Builder) ToSql

func (this *Builder) ToSql() string

func (*Builder) Union

func (this *Builder) Union(builder contracts.QueryBuilder, unionType ...contracts.UnionJoinType) contracts.QueryBuilder

func (*Builder) UnionAll

func (this *Builder) UnionAll(builder contracts.QueryBuilder) contracts.QueryBuilder

func (*Builder) UnionAllByProvider

func (this *Builder) UnionAllByProvider(builder contracts.QueryProvider) contracts.QueryBuilder

func (*Builder) UnionByProvider

func (this *Builder) UnionByProvider(builder contracts.QueryProvider, unionType ...contracts.UnionJoinType) contracts.QueryBuilder

func (*Builder) Update

func (this *Builder) Update(fields contracts.Fields) int64

func (*Builder) UpdateOrCreate added in v0.1.2

func (this *Builder) UpdateOrCreate(attributes contracts.Fields, values ...contracts.Fields) interface{}

func (*Builder) UpdateOrInsert added in v0.1.2

func (this *Builder) UpdateOrInsert(attributes contracts.Fields, values ...contracts.Fields) bool

func (*Builder) UpdateSql

func (this *Builder) UpdateSql(value contracts.Fields) (sql string, bindings []interface{})

func (*Builder) When

func (this *Builder) When(condition bool, callback contracts.QueryCallback, elseCallback ...contracts.QueryCallback) contracts.QueryBuilder

func (*Builder) Where

func (this *Builder) Where(field string, args ...interface{}) contracts.QueryBuilder

func (*Builder) WhereBetween

func (this *Builder) WhereBetween(field string, args interface{}, whereType ...contracts.WhereJoinType) contracts.QueryBuilder

WhereBetween args 参数可以是整数、浮点数、字符串、interface{} 等类型的数组,或者用` and `隔开的字符串,或者在源码中了解更多 https://github.com/goal-web/querybuilder/blob/78bcc832604bfcdb68579e3dd1441796a16994cf/builder.go#L74

func (*Builder) WhereExists

func (this *Builder) WhereExists(provider contracts.QueryProvider, where ...contracts.WhereJoinType) contracts.QueryBuilder

func (*Builder) WhereFields added in v0.1.4

func (this *Builder) WhereFields(fields contracts.Fields) contracts.QueryBuilder

func (*Builder) WhereFunc

func (this *Builder) WhereFunc(callback contracts.QueryFunc, whereType ...contracts.WhereJoinType) contracts.QueryBuilder

func (*Builder) WhereIn

func (this *Builder) WhereIn(field string, args interface{}, joinType ...contracts.WhereJoinType) contracts.QueryBuilder

WhereIn args 参数可以是整数、浮点数、字符串、interface{} 等类型的数组,或者用` and `隔开的字符串,或者在源码中了解更多 https://github.com/goal-web/querybuilder/blob/78bcc832604bfcdb68579e3dd1441796a16994cf/builder.go#L74

func (*Builder) WhereIsNull

func (this *Builder) WhereIsNull(field string, whereType ...contracts.WhereJoinType) contracts.QueryBuilder

func (*Builder) WhereNotBetween

func (this *Builder) WhereNotBetween(field string, args interface{}, whereType ...contracts.WhereJoinType) contracts.QueryBuilder

func (*Builder) WhereNotExists

func (this *Builder) WhereNotExists(provider contracts.QueryProvider, where ...contracts.WhereJoinType) contracts.QueryBuilder

func (*Builder) WhereNotIn

func (this *Builder) WhereNotIn(field string, args interface{}, joinType ...contracts.WhereJoinType) contracts.QueryBuilder

func (*Builder) WhereNotNull

func (this *Builder) WhereNotNull(field string, whereType ...contracts.WhereJoinType) contracts.QueryBuilder

func (*Builder) WithAvg added in v0.1.2

func (this *Builder) WithAvg(field string, as ...string) contracts.QueryBuilder

func (*Builder) WithCount added in v0.1.2

func (this *Builder) WithCount(fields ...string) contracts.QueryBuilder

func (*Builder) WithMax added in v0.1.2

func (this *Builder) WithMax(field string, as ...string) contracts.QueryBuilder

func (*Builder) WithMin added in v0.1.2

func (this *Builder) WithMin(field string, as ...string) contracts.QueryBuilder

func (*Builder) WithPagination

func (this *Builder) WithPagination(perPage int64, current ...int64) contracts.QueryBuilder

func (*Builder) WithSum added in v0.1.2

func (this *Builder) WithSum(field string, as ...string) contracts.QueryBuilder

type GroupBy

type GroupBy []string

func (GroupBy) IsEmpty

func (this GroupBy) IsEmpty() bool

func (GroupBy) String

func (this GroupBy) String() string

type Join

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

func (Join) String

func (this Join) String() (result string)

type Joins

type Joins []Join

func (Joins) IsEmpty

func (this Joins) IsEmpty() bool

func (Joins) String

func (this Joins) String() (result string)

type OrderBy

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

type OrderByFields

type OrderByFields []OrderBy

func (OrderByFields) IsEmpty

func (this OrderByFields) IsEmpty() bool

func (OrderByFields) String

func (this OrderByFields) String() string

type ParamException

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

func (ParamException) Error

func (p ParamException) Error() string

func (ParamException) Fields

func (p ParamException) Fields() contracts.Fields

type Unions

func (Unions) IsEmpty

func (this Unions) IsEmpty() bool

func (Unions) String

func (this Unions) String() (result string)

type Where

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

func (*Where) String

func (this *Where) String() string

type Wheres

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

func (*Wheres) IsEmpty

func (this *Wheres) IsEmpty() bool

func (*Wheres) String

func (this *Wheres) String() (result string)

Jump to

Keyboard shortcuts

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