query

package
v0.0.0-...-b7c8a0c Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractTableName

func ExtractTableName(sql string) string

Types

type CKInsert

type CKInsert struct {
	TableName string
	Columns   []string
}

func NewCKInsert

func NewCKInsert(tableName string) *CKInsert

func (*CKInsert) AddColumn

func (c *CKInsert) AddColumn(col ...string) *CKInsert

func (*CKInsert) AddValues

func (c *CKInsert) AddValues(vals ...[]any)

func (*CKInsert) Build

func (c *CKInsert) Build() (string, []any)

func (*CKInsert) Clear

func (c *CKInsert) Clear()

type EsQuery

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

EsQuery 用于构建 Elasticsearch 查询

func NewESFilterQuery

func NewESFilterQuery() *EsQuery

NewFilterQuery 创建一个新的过滤器查询

func NewESMustNotQuery

func NewESMustNotQuery() *EsQuery

NewMustNotQuery 创建一个新的must_not查询

func NewESMustQuery

func NewESMustQuery() *EsQuery

NewMustQuery 创建一个新的must查询

func NewESShouldQuery

func NewESShouldQuery(num int) *EsQuery

NewShouldQuery 创建一个新的should查询

func (*EsQuery) Between

func (q *EsQuery) Between(field string, lower, upper any) *EsQuery

Range 方法用于生成 field between lower and upper 的range语句

func (*EsQuery) Build

func (q *EsQuery) Build() elastic.Query

Build 方法用于生成es查询

func (*EsQuery) Eq

func (q *EsQuery) Eq(field string, value any) *EsQuery

Eq 方法用于生成 field = value 的term语句

func (*EsQuery) Exists

func (q *EsQuery) Exists(field string) *EsQuery

Exists 方法用于生成exists查询,检查字段是否存在

func (*EsQuery) Filter

func (q *EsQuery) Filter(clauses *EsQuery) *EsQuery

Filter 方法用于生成filter查询

func (*EsQuery) Fuzzy

func (q *EsQuery) Fuzzy(field string, value string) *EsQuery

fuzzy 用于生成 模糊查询语句

func (*EsQuery) Gt

func (q *EsQuery) Gt(field string, value any) *EsQuery

Range 方法用于生成 field > value 的range语句

func (*EsQuery) Gte

func (q *EsQuery) Gte(field string, value any) *EsQuery

Range 方法用于生成 field >= value 的range语句

func (*EsQuery) In

func (q *EsQuery) In(field string, values ...any) *EsQuery

In 方法用于生成 field IN (value1, value2, ...) 的terms语句

func (*EsQuery) Like

func (q *EsQuery) Like(field string, value string) *EsQuery

Like 方法用于生成正则查询语句

func (*EsQuery) Lt

func (q *EsQuery) Lt(field string, value any) *EsQuery

Range 方法用于生成 field < value 的range语句

func (*EsQuery) Lte

func (q *EsQuery) Lte(field string, value any) *EsQuery

Range 方法用于生成 field <= value 的range语句

func (*EsQuery) Must

func (q *EsQuery) Must(clauses *EsQuery) *EsQuery

Must 方法用于生成must查询

func (*EsQuery) MustNot

func (q *EsQuery) MustNot(clauses *EsQuery) *EsQuery

MustNot 方法用于生成must_not查询

func (*EsQuery) Neq

func (q *EsQuery) Neq(field string, value any) *EsQuery

Range 方法用于生成 field != value 的range语句

func (*EsQuery) NotExists

func (q *EsQuery) NotExists(field string) *EsQuery

NotExists 方法用于生成exists查询,检查字段是否不存在

func (*EsQuery) NotIn

func (q *EsQuery) NotIn(field string, values ...any) *EsQuery

NotIn 方法用于生成 field NOT IN (value1, value2, ...) 的terms语句

func (*EsQuery) NotLike

func (q *EsQuery) NotLike(field string, value string) *EsQuery

NotLike 方法用于生成正则查询语句的not结果

func (*EsQuery) NotPrefix

func (q *EsQuery) NotPrefix(field string, value string) *EsQuery

NotPrefix 用于生成前缀查询语句的not结果

func (*EsQuery) NotWildcard

func (q *EsQuery) NotWildcard(field string, value string) *EsQuery

NotWildcard 用于生成通配符查询语句的not结果

func (*EsQuery) Prefix

func (q *EsQuery) Prefix(field string, value string) *EsQuery

prefix 用于生成 前缀查询语句

func (*EsQuery) Script

func (q *EsQuery) Script(script string, params map[string]any, lang string) *EsQuery

Script 方法用于生成脚本查询

func (*EsQuery) ScriptID

func (q *EsQuery) ScriptID(scriptID string) *EsQuery

ScriptID 方法用于生成脚本查询

func (*EsQuery) Should

func (q *EsQuery) Should(clauses *EsQuery, should int) *EsQuery

Should 方法用于生成should查询

func (*EsQuery) Source

func (q *EsQuery) Source() string

Source 方法用于获取es查询语句

func (*EsQuery) Wildcard

func (q *EsQuery) Wildcard(field string, value string) *EsQuery

Wildcard 方法用于生成通配符查询语句

type MysqlInsert

type MysqlInsert struct {
	TableName     string
	Columns       []string
	UpdateColumns []string
	InsertValues  [][]any
	IsUpdate      bool
	IsReplace     bool
	IsIgnore      bool
}

func NewMysqlInsert

func NewMysqlInsert(tableName string, Replace bool, ignore bool) *MysqlInsert

func (*MysqlInsert) AddColumn

func (m *MysqlInsert) AddColumn(col ...string) *MysqlInsert

func (*MysqlInsert) AddUpdateColumn

func (m *MysqlInsert) AddUpdateColumn(col ...string) *MysqlInsert

func (*MysqlInsert) AddValue

func (m *MysqlInsert) AddValue(vals ...any) *MysqlInsert

func (*MysqlInsert) AddValues

func (m *MysqlInsert) AddValues(vals ...[]any)

func (*MysqlInsert) Build

func (m *MysqlInsert) Build() (string, []any)

func (*MysqlInsert) Clear

func (m *MysqlInsert) Clear()

type SQLBuilder

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

SQLBuilder 结构体用于构建 SQL 查询

func NewSQLBuilder

func NewSQLBuilder() *SQLBuilder

NewSQLBuilder 返回一个新的 SQLBuilder 实例

func (*SQLBuilder) And

func (sb *SQLBuilder) And(clauses ...string) *SQLBuilder

And 方法用于添加 AND 条件

func (*SQLBuilder) Between

func (sb *SQLBuilder) Between(field string, lower, upper any) *SQLBuilder

Between 方法用于生成 field BETWEEN lower AND upper 的条件语句

func (*SQLBuilder) Build

func (sb *SQLBuilder) Build() string

Build 方法用于构建最终的 SQL 查询语句

func (*SQLBuilder) Clear

func (sb *SQLBuilder) Clear()

func (*SQLBuilder) Copy

func (sb *SQLBuilder) Copy() *SQLBuilder

func (*SQLBuilder) Eq

func (sb *SQLBuilder) Eq(field string, value any) *SQLBuilder

equal 方法用语添加 等于的条件到where中

func (*SQLBuilder) From

func (sb *SQLBuilder) From(tableName any) *SQLBuilder

From 方法用于指定查询的表名

func (*SQLBuilder) GroupBy

func (sb *SQLBuilder) GroupBy(fields ...string) *SQLBuilder

GroupBy 方法用于指定 GROUP BY 子句

func (*SQLBuilder) Gt

func (sb *SQLBuilder) Gt(field string, value any) *SQLBuilder

gt 方法用语添加 大于的条件到where中

func (*SQLBuilder) Gte

func (sb *SQLBuilder) Gte(field string, value any) *SQLBuilder

gte 方法用语添加 大于等于的条件到where中

func (*SQLBuilder) In

func (sb *SQLBuilder) In(field string, values any) *SQLBuilder

In 方法用于生成 field IN (subquery) 或 field IN (value1, value2, ...) 的条件语句

func (*SQLBuilder) Limit

func (sb *SQLBuilder) Limit(limit int) *SQLBuilder

Limit 方法用于指定 LIMIT 子句

func (*SQLBuilder) Lt

func (sb *SQLBuilder) Lt(field string, value any) *SQLBuilder

lt 方法用语添加 小于的条件到where中

func (*SQLBuilder) Lte

func (sb *SQLBuilder) Lte(field string, value any) *SQLBuilder

lte 方法用语添加 小于等于的条件到where中

func (*SQLBuilder) Offset

func (sb *SQLBuilder) Offset(offset int) *SQLBuilder

Offset 方法用于指定 OFFSET 子句

func (*SQLBuilder) Or

func (sb *SQLBuilder) Or(clauses ...string) *SQLBuilder

Or 方法用于添加 OR 条件

func (*SQLBuilder) OrderBy

func (sb *SQLBuilder) OrderBy(fields ...string) *SQLBuilder

OrderBy 方法用于指定 ORDER BY 子句

func (*SQLBuilder) Select

func (sb *SQLBuilder) Select(fields ...string) *SQLBuilder

Select 方法用于指定选择的字段

func (*SQLBuilder) TableName

func (sb *SQLBuilder) TableName() string

func (*SQLBuilder) TransformSelect

func (sb *SQLBuilder) TransformSelect(transformFunc func(string) string) *SQLBuilder

TransformSelect 方法用于对 SELECT 字段进行转换处理

func (*SQLBuilder) Uneq

func (sb *SQLBuilder) Uneq(field string, value any) *SQLBuilder

unequal 方法用语添加 不等于的条件到where中

func (*SQLBuilder) Where

func (sb *SQLBuilder) Where(clauses ...string) *SQLBuilder

Where 方法用于添加 WHERE 子句条件

type SqlInsert

type SqlInsert interface {
	AddValues(vals ...[]any)
	Build() (string, []any)
	Clear()
}

Jump to

Keyboard shortcuts

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