Documentation
¶
Index ¶
- type Query
- func (q *Query) Avg(col string) *Query
- func (q *Query) Build() (string, []any, error)
- func (q *Query) Count(cols ...string) (int64, error)
- func (q *Query) CrossJoin(table string) *Query
- func (q *Query) Delete() (sql.Result, error)
- func (q *Query) Distinct(cols ...string) *Query
- func (q *Query) Dump() (string, []any, error)
- func (q *Query) First(dest any) error
- func (q *Query) FirstMap(dest *map[string]any) error
- func (q *Query) Get(dest any) error
- func (q *Query) GetMaps(dest *[]map[string]any) error
- func (q *Query) GroupBy(cols ...string) *Query
- func (q *Query) Having(col, cond string, val any) *Query
- func (q *Query) HavingRaw(raw string) *Query
- func (q *Query) Insert(data any) (sql.Result, error)
- func (q *Query) InsertBatch(data []map[string]any) (sql.Result, error)
- func (q *Query) InsertGetId(data any) (int64, error)
- func (q *Query) InsertOrIgnore(data []map[string]any) (sql.Result, error)
- func (q *Query) InsertUsing(columns []string, sub *Query) (sql.Result, error)
- func (q *Query) Join(table, localColumn, cond, target string) *Query
- func (q *Query) JoinLateral(sub *Query, alias string) *Query
- func (q *Query) JoinQuery(table string, fn func(b *qbapi.JoinClauseQueryBuilder)) *Query
- func (q *Query) JoinSubQuery(sub *Query, alias, my, condition, target string) *Query
- func (q *Query) LeftJoin(table, localColumn, cond, target string) *Query
- func (q *Query) LeftJoinLateral(sub *Query, alias string) *Query
- func (q *Query) LeftJoinQuery(table string, fn func(b *qbapi.JoinClauseQueryBuilder)) *Query
- func (q *Query) LeftJoinSubQuery(sub *Query, alias, my, condition, target string) *Query
- func (q *Query) Limit(n int) *Query
- func (q *Query) LockForUpdate() *Query
- func (q *Query) Max(col string) *Query
- func (q *Query) Min(col string) *Query
- func (q *Query) Offset(n int) *Query
- func (q *Query) OrHaving(col, cond string, val any) *Query
- func (q *Query) OrHavingRaw(raw string) *Query
- func (q *Query) OrWhere(col string, args ...any) *Query
- func (q *Query) OrWhereBetween(col string, min, max any) *Query
- func (q *Query) OrWhereBetweenColumns(col, minCol, maxCol string) *Query
- func (q *Query) OrWhereColumn(col string, args ...string) *Query
- func (q *Query) OrWhereColumns(columns [][]string) *Query
- func (q *Query) OrWhereDate(col, cond, date string) *Query
- func (q *Query) OrWhereDay(col, cond, day string) *Query
- func (q *Query) OrWhereExists(sub *Query) *Query
- func (q *Query) OrWhereFullText(cols []string, search string, opts map[string]any) *Query
- func (q *Query) OrWhereGroup(fn func(g *Query)) *Query
- func (q *Query) OrWhereIn(col string, vals any) *Query
- func (q *Query) OrWhereInSubQuery(col string, sub *Query) *Query
- func (q *Query) OrWhereMonth(col, cond, month string) *Query
- func (q *Query) OrWhereNot(fn func(g *Query)) *Query
- func (q *Query) OrWhereNotBetween(col string, min, max any) *Query
- func (q *Query) OrWhereNotBetweenColumns(col, minCol, maxCol string) *Query
- func (q *Query) OrWhereNotExists(sub *Query) *Query
- func (q *Query) OrWhereNotIn(col string, vals any) *Query
- func (q *Query) OrWhereNotInSubQuery(col string, sub *Query) *Query
- func (q *Query) OrWhereNotNull(col string) *Query
- func (q *Query) OrWhereNull(col string) *Query
- func (q *Query) OrWhereRaw(raw string, vals map[string]any) *Query
- func (q *Query) OrWhereTime(col, cond, time string) *Query
- func (q *Query) OrWhereYear(col, cond, year string) *Query
- func (q *Query) OrderBy(col, dir string) *Query
- func (q *Query) OrderByRaw(raw string) *Query
- func (q *Query) PrimaryKey(col string) *Query
- func (q *Query) RawSQL() (string, error)
- func (q *Query) ReOrder() *Query
- func (q *Query) RightJoin(table, localColumn, cond, target string) *Query
- func (q *Query) RightJoinQuery(table string, fn func(b *qbapi.JoinClauseQueryBuilder)) *Query
- func (q *Query) RightJoinSubQuery(sub *Query, alias, my, condition, target string) *Query
- func (q *Query) SafeOrWhereRaw(raw string, vals map[string]any) *Query
- func (q *Query) SafeWhereRaw(raw string, vals map[string]any) *Query
- func (q *Query) Select(cols ...string) *Query
- func (q *Query) SelectRaw(raw string, values ...any) *Query
- func (q *Query) SharedLock() *Query
- func (q *Query) Skip(n int) *Query
- func (q *Query) Sum(col string) *Query
- func (q *Query) Take(n int) *Query
- func (q *Query) Union(sub *Query) *Query
- func (q *Query) UnionAll(sub *Query) *Query
- func (q *Query) Update(data any) (sql.Result, error)
- func (q *Query) UpdateOrInsert(cond map[string]any, values map[string]any) (sql.Result, error)
- func (q *Query) Upsert(data []map[string]any, unique []string, updateCols []string) (sql.Result, error)
- func (q *Query) Where(col string, args ...any) *Query
- func (q *Query) WhereAll(cols []string, cond string, val any) *Query
- func (q *Query) WhereAny(cols []string, cond string, val any) *Query
- func (q *Query) WhereBetween(col string, min, max any) *Query
- func (q *Query) WhereBetweenColumns(col, minCol, maxCol string) *Query
- func (q *Query) WhereColumn(col string, args ...string) *Query
- func (q *Query) WhereColumns(columns [][]string) *Query
- func (q *Query) WhereDate(col, cond, date string) *Query
- func (q *Query) WhereDay(col, cond, day string) *Query
- func (q *Query) WhereExists(sub *Query) *Query
- func (q *Query) WhereFullText(cols []string, search string, opts map[string]any) *Query
- func (q *Query) WhereGroup(fn func(g *Query)) *Query
- func (q *Query) WhereIn(col string, vals any) *Query
- func (q *Query) WhereInSubQuery(col string, sub *Query) *Query
- func (q *Query) WhereMonth(col, cond, month string) *Query
- func (q *Query) WhereNot(fn func(g *Query)) *Query
- func (q *Query) WhereNotBetween(col string, min, max any) *Query
- func (q *Query) WhereNotBetweenColumns(col, minCol, maxCol string) *Query
- func (q *Query) WhereNotExists(sub *Query) *Query
- func (q *Query) WhereNotIn(col string, vals any) *Query
- func (q *Query) WhereNotInSubQuery(col string, sub *Query) *Query
- func (q *Query) WhereNotNull(col string) *Query
- func (q *Query) WhereNull(col string) *Query
- func (q *Query) WhereRaw(raw string, vals map[string]any) *Query
- func (q *Query) WhereTime(col, cond, time string) *Query
- func (q *Query) WhereYear(col, cond, year string) *Query
- func (q *Query) WithContext(ctx context.Context) *Query
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Query ¶
type Query struct {
// contains filtered or unexported fields
}
Query wraps goquent QueryBuilder and the executor.
func (*Query) Count ¶
Count executes a COUNT query using the current conditions and returns the resulting row count.
func (*Query) InsertBatch ¶
InsertBatch executes a bulk INSERT with the given slice of data maps.
func (*Query) InsertGetId ¶
InsertGetId executes an INSERT and returns the auto-increment ID. For PostgreSQL, it appends a RETURNING clause for the configured primary key column because the driver does not support LastInsertId.
func (*Query) InsertOrIgnore ¶
InsertOrIgnore executes an INSERT IGNORE.
func (*Query) InsertUsing ¶
InsertUsing executes an INSERT INTO ... SELECT statement using columns from a subquery.
func (*Query) JoinLateral ¶ added in v0.0.7
JoinLateral performs a LATERAL JOIN using a subquery.
func (*Query) JoinQuery ¶ added in v0.0.7
func (q *Query) JoinQuery(table string, fn func(b *qbapi.JoinClauseQueryBuilder)) *Query
JoinQuery adds a JOIN with additional ON/WHERE clauses defined in the callback.
func (*Query) JoinSubQuery ¶ added in v0.0.7
JoinSubQuery joins a subquery with alias and join condition.
func (*Query) LeftJoinLateral ¶ added in v0.0.7
LeftJoinLateral performs a LEFT LATERAL JOIN using a subquery.
func (*Query) LeftJoinQuery ¶ added in v0.0.7
func (q *Query) LeftJoinQuery(table string, fn func(b *qbapi.JoinClauseQueryBuilder)) *Query
LeftJoinQuery adds a LEFT JOIN with additional clauses defined in the callback.
func (*Query) LeftJoinSubQuery ¶ added in v0.0.7
LeftJoinSubQuery performs a LEFT JOIN using a subquery.
func (*Query) LockForUpdate ¶
LockForUpdate adds FOR UPDATE clause.
func (*Query) OrHavingRaw ¶
OrHavingRaw adds raw OR HAVING condition.
func (*Query) OrWhereBetween ¶
OrWhereBetween adds OR WHERE BETWEEN condition.
func (*Query) OrWhereBetweenColumns ¶
OrWhereBetweenColumns adds OR WHERE col BETWEEN minCol AND maxCol using columns.
func (*Query) OrWhereColumn ¶
OrWhereColumn adds OR WHERE column operator column condition.
func (*Query) OrWhereColumns ¶
OrWhereColumns adds multiple column comparison conditions joined by OR.
func (*Query) OrWhereDate ¶
OrWhereDate adds OR WHERE DATE(column) comparison condition.
func (*Query) OrWhereDay ¶
OrWhereDay adds OR WHERE DAY(column) comparison condition.
func (*Query) OrWhereExists ¶
OrWhereExists adds OR WHERE EXISTS (subquery) condition.
func (*Query) OrWhereFullText ¶
OrWhereFullText adds OR full-text search condition.
func (*Query) OrWhereGroup ¶ added in v0.0.7
OrWhereGroup groups conditions with parentheses using OR logic.
func (*Query) OrWhereInSubQuery ¶
OrWhereInSubQuery adds OR WHERE IN (subquery) condition.
func (*Query) OrWhereMonth ¶
OrWhereMonth adds OR WHERE MONTH(column) comparison condition.
func (*Query) OrWhereNot ¶ added in v0.0.7
OrWhereNot groups conditions inside OR NOT (...).
func (*Query) OrWhereNotBetween ¶
OrWhereNotBetween adds OR WHERE NOT BETWEEN condition.
func (*Query) OrWhereNotBetweenColumns ¶
OrWhereNotBetweenColumns adds OR WHERE col NOT BETWEEN minCol AND maxCol using columns.
func (*Query) OrWhereNotExists ¶
OrWhereNotExists adds OR WHERE NOT EXISTS (subquery) condition.
func (*Query) OrWhereNotIn ¶
OrWhereNotIn adds OR WHERE NOT IN condition.
func (*Query) OrWhereNotInSubQuery ¶
OrWhereNotInSubQuery adds OR WHERE NOT IN (subquery) condition.
func (*Query) OrWhereNotNull ¶
OrWhereNotNull adds OR WHERE column IS NOT NULL condition.
func (*Query) OrWhereNull ¶
OrWhereNull adds OR WHERE column IS NULL condition.
func (*Query) OrWhereRaw ¶
OrWhereRaw appends raw OR WHERE condition.
func (*Query) OrWhereTime ¶
OrWhereTime adds OR WHERE TIME(column) comparison condition.
func (*Query) OrWhereYear ¶
OrWhereYear adds OR WHERE YEAR(column) comparison condition.
func (*Query) OrderByRaw ¶
OrderByRaw adds raw ORDER BY clause.
func (*Query) PrimaryKey ¶ added in v0.2.1
PrimaryKey sets the primary key column for the table.
func (*Query) RightJoinQuery ¶ added in v0.0.7
func (q *Query) RightJoinQuery(table string, fn func(b *qbapi.JoinClauseQueryBuilder)) *Query
RightJoinQuery adds a RIGHT JOIN with additional clauses defined in the callback.
func (*Query) RightJoinSubQuery ¶ added in v0.0.7
RightJoinSubQuery performs a RIGHT JOIN using a subquery.
func (*Query) SafeOrWhereRaw ¶ added in v0.0.7
SafeOrWhereRaw appends a raw OR WHERE condition ensuring a values map is used.
func (*Query) SafeWhereRaw ¶ added in v0.0.7
SafeWhereRaw appends a raw WHERE condition ensuring a values map is always used.
func (*Query) SharedLock ¶
SharedLock adds LOCK IN SHARE MODE clause.
func (*Query) UpdateOrInsert ¶
UpdateOrInsert performs UPDATE or INSERT based on condition.
func (*Query) Upsert ¶
func (q *Query) Upsert(data []map[string]any, unique []string, updateCols []string) (sql.Result, error)
Upsert executes an UPSERT using ON DUPLICATE KEY UPDATE.
func (*Query) Where ¶
Where appends a column/value comparison. Values are always treated as literals. Use WhereColumn for column-to-column comparisons.
func (*Query) WhereBetween ¶
WhereBetween adds WHERE BETWEEN condition.
func (*Query) WhereBetweenColumns ¶
WhereBetweenColumns adds WHERE col BETWEEN minCol AND maxCol using columns.
func (*Query) WhereColumn ¶
WhereColumn adds WHERE column operator column condition.
func (*Query) WhereColumns ¶
WhereColumns adds multiple column comparison conditions joined by AND.
func (*Query) WhereExists ¶
WhereExists adds WHERE EXISTS (subquery) condition.
func (*Query) WhereFullText ¶
WhereFullText adds full-text search condition.
func (*Query) WhereGroup ¶ added in v0.0.7
WhereGroup groups conditions with parentheses using AND logic.
func (*Query) WhereInSubQuery ¶
WhereInSubQuery adds WHERE IN (subquery) condition.
func (*Query) WhereMonth ¶
WhereMonth adds WHERE MONTH(column) comparison condition.
func (*Query) WhereNotBetween ¶
WhereNotBetween adds WHERE NOT BETWEEN condition.
func (*Query) WhereNotBetweenColumns ¶
WhereNotBetweenColumns adds WHERE col NOT BETWEEN minCol AND maxCol using columns.
func (*Query) WhereNotExists ¶
WhereNotExists adds WHERE NOT EXISTS (subquery) condition.
func (*Query) WhereNotIn ¶
WhereNotIn adds WHERE NOT IN condition.
func (*Query) WhereNotInSubQuery ¶
WhereNotInSubQuery adds WHERE NOT IN (subquery) condition.
func (*Query) WhereNotNull ¶
WhereNotNull adds WHERE column IS NOT NULL condition.