Documentation
¶
Overview ¶
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-10 01:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-11 09:20:54 * @FilePath: \go-sqlbuilder\adapters.go * @Description: Database adapters for sqlx, gorm and other ORM frameworks * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 21:13:15 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:09:38 * @FilePath: \go-sqlbuilder\builder_enhancer.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 21:13:15 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:07:41 * @FilePath: \go-sqlbuilder\compat.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-10 01:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-10 23:34:00 * @FilePath: \go-sqlbuilder\interfaces.go * @Description: Database interfaces for multiple ORM compatibility (sqlx, gorm, etc.) * * Copyright (c) 2024 by kamalyes, All Rights Reserved.
Index ¶
- Constants
- func GetSupportedAdapters() []string
- func RegisterAdapter(name string, creator func() DriverAdapterInterface)
- type AdapterCompatibilityCheck
- type AdapterFactory
- type AdvancedQueryInterface
- type AdvancedQueryParamdeprecated
- type BackwardCompatibility
- type BaseInfoFilterdeprecated
- type BatchOperationInterface
- type BuildMetrics
- type Builder
- func (b *Builder) As(alias string) *Builder
- func (b *Builder) BatchInsert(data []map[string]interface{}) error
- func (b *Builder) BatchUpdate(data []map[string]interface{}, whereColumns []string) error
- func (b *Builder) Close() error
- func (b *Builder) Count() (int64, error)
- func (b *Builder) CrossJoin(table string) *Builder
- func (b *Builder) Decrement(column string, value int64) error
- func (b *Builder) Delete() *Builder
- func (b *Builder) Distinct() *Builder
- func (b *Builder) Exec() (sql.Result, error)
- func (b *Builder) Exists() (bool, error)
- func (b *Builder) First(dest interface{}) error
- func (b *Builder) FullJoin(table, on string, args ...interface{}) *Builder
- func (b *Builder) Get(dest interface{}) error
- func (b *Builder) GetAdapter() UniversalAdapterInterface
- func (b *Builder) GroupBy(columns ...string) *Builder
- func (b *Builder) Having(column, operator string, value interface{}) *Builder
- func (b *Builder) HavingRaw(sql string, args ...interface{}) *Builder
- func (b *Builder) Increment(column string, value int64) error
- func (b *Builder) Insert(data map[string]interface{}) *Builder
- func (b *Builder) InsertGetID(data map[string]interface{}) (int64, error)
- func (b *Builder) Join(table, on string, args ...interface{}) *Builder
- func (b *Builder) LeftJoin(table, on string, args ...interface{}) *Builder
- func (b *Builder) Limit(limit int64) *Builder
- func (b *Builder) Offset(offset int64) *Builder
- func (b *Builder) OrWhere(column string, operator string, value interface{}) *Builder
- func (b *Builder) OrWhereRaw(sql string, args ...interface{}) *Builder
- func (b *Builder) OrderBy(column string) *Builder
- func (b *Builder) OrderByDesc(column string) *Builder
- func (b *Builder) OrderByRaw(sql string) *Builder
- func (b *Builder) Paginate(page, pageSize int64) *Builder
- func (b *Builder) Ping() error
- func (b *Builder) RightJoin(table, on string, args ...interface{}) *Builder
- func (b *Builder) Select(columns ...string) *Builder
- func (b *Builder) SelectRaw(sql string, args ...interface{}) *Builder
- func (b *Builder) Set(column string, value interface{}) *Builder
- func (b *Builder) Table(table string) *Builder
- func (b *Builder) ToSQL() (string, []interface{})
- func (b *Builder) Transaction(fn func(*Builder) error) error
- func (b *Builder) Update(data map[string]interface{}) (*Builder, error)
- func (b *Builder) Where(column string, operator string, value interface{}) *Builder
- func (b *Builder) WhereBetween(column string, min, max interface{}) *Builder
- func (b *Builder) WhereIn(column string, values ...interface{}) *Builder
- func (b *Builder) WhereLike(column, value string) *Builder
- func (b *Builder) WhereNotIn(column string, values ...interface{}) *Builder
- func (b *Builder) WhereNotNull(column string) *Builder
- func (b *Builder) WhereNull(column string) *Builder
- func (b *Builder) WhereRaw(sql string, args ...interface{}) *Builder
- func (b *Builder) WithContext(ctx context.Context) *Builder
- func (b *Builder) WithTimeout(timeout time.Duration) *Builder
- type BuilderEnhancer
- func (be *BuilderEnhancer) AddMiddleware(middlewares ...middleware.Middleware) *BuilderEnhancer
- func (be *BuilderEnhancer) GetBuilder() *Builder
- func (be *BuilderEnhancer) GetCompiler() compiler.SQLCompiler
- func (be *BuilderEnhancer) GetExecutor() executor.Executor
- func (be *BuilderEnhancer) GetMiddlewareChain() middleware.ExecutionChain
- func (be *BuilderEnhancer) GetPlanner() compiler.Planner
- type BuilderV2
- func (b *BuilderV2) Build() (string, []interface{}, error)
- func (b *BuilderV2) GetMetrics() map[string]interface{}
- func (b *BuilderV2) Limit(limit int64) *BuilderV2
- func (b *BuilderV2) OrderBy(field, direction string) *BuilderV2
- func (b *BuilderV2) Select(columns ...string) *BuilderV2
- func (b *BuilderV2) Table(table string) *BuilderV2
- func (b *BuilderV2) Where(field string, operator interface{}, value ...interface{}) *BuilderV2
- type CacheInterface
- type CloseInterface
- type CompatibilityCheck
- type ConnectionPoolInterface
- type ConnectionStats
- type CreateOptions
- type CreateResult
- type DatabaseAdapterWrapper
- func (w *DatabaseAdapterWrapper) BatchInsert(ctx context.Context, table string, data []map[string]interface{}) error
- func (w *DatabaseAdapterWrapper) BatchUpdate(ctx context.Context, table string, data []map[string]interface{}, ...) error
- func (w *DatabaseAdapterWrapper) Begin() (TransactionInterface, error)
- func (w *DatabaseAdapterWrapper) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
- func (w *DatabaseAdapterWrapper) Close() error
- func (w *DatabaseAdapterWrapper) Commit() error
- func (w *DatabaseAdapterWrapper) Exec(query string, args ...interface{}) (sql.Result, error)
- func (w *DatabaseAdapterWrapper) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (w *DatabaseAdapterWrapper) GetAdapterName() string
- func (w *DatabaseAdapterWrapper) GetAdapterType() string
- func (w *DatabaseAdapterWrapper) GetDialect() string
- func (w *DatabaseAdapterWrapper) GetInstance() interface{}
- func (w *DatabaseAdapterWrapper) GetStats() ConnectionStats
- func (w *DatabaseAdapterWrapper) Ping() error
- func (w *DatabaseAdapterWrapper) PingContext(ctx context.Context) error
- func (w *DatabaseAdapterWrapper) Prepare(query string) (StatementInterface, error)
- func (w *DatabaseAdapterWrapper) PrepareContext(ctx context.Context, query string) (StatementInterface, error)
- func (w *DatabaseAdapterWrapper) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (w *DatabaseAdapterWrapper) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (w *DatabaseAdapterWrapper) QueryRow(query string, args ...interface{}) *sql.Row
- func (w *DatabaseAdapterWrapper) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (w *DatabaseAdapterWrapper) Rollback() error
- func (w *DatabaseAdapterWrapper) SupportsBulkInsert() bool
- func (w *DatabaseAdapterWrapper) SupportsORM() bool
- func (w *DatabaseAdapterWrapper) SupportsReturning() bool
- func (w *DatabaseAdapterWrapper) SupportsUpsert() bool
- type DatabaseInterface
- type DeleteOptions
- type DeleteResult
- type DriverAdapterInterface
- type EmailRule
- type EnhancedBuilder
- func (eb *EnhancedBuilder) Add(data map[string]interface{}) error
- func (eb *EnhancedBuilder) AddAuditFields(fields ...string) *EnhancedBuilder
- func (eb *EnhancedBuilder) AddHook(event string, hook HookFunc) *EnhancedBuilder
- func (eb *EnhancedBuilder) AddValidation(field string, rule ValidationRule) *EnhancedBuilder
- func (eb *EnhancedBuilder) BatchUpsert(ctx context.Context, data []map[string]interface{}, conflictFields []string) error
- func (eb *EnhancedBuilder) Count() (int64, error)
- func (eb *EnhancedBuilder) Create(data map[string]interface{}) error
- func (eb *EnhancedBuilder) Delete(id interface{}) error
- func (eb *EnhancedBuilder) EnableSoftDelete(enable bool) *EnhancedBuilder
- func (eb *EnhancedBuilder) Find(page, pageSize int64) ([]map[string]interface{}, error)
- func (eb *EnhancedBuilder) Get(id interface{}) (map[string]interface{}, error)
- func (eb *EnhancedBuilder) List(page, pageSize int64) ([]map[string]interface{}, error)
- func (eb *EnhancedBuilder) Read(id interface{}) (map[string]interface{}, error)
- func (eb *EnhancedBuilder) Save(data map[string]interface{}) error
- func (eb *EnhancedBuilder) Search(field, keyword string, page, pageSize int64) ([]map[string]interface{}, error)
- func (eb *EnhancedBuilder) SmartCreate(ctx context.Context, data map[string]interface{}, options *CreateOptions) (*CreateResult, error)
- func (eb *EnhancedBuilder) SmartDelete(ctx context.Context, id interface{}, options *DeleteOptions) (*DeleteResult, error)
- func (eb *EnhancedBuilder) SmartFind(ctx context.Context, options *FindOptions) (*FindResult, error)
- func (eb *EnhancedBuilder) SmartUpdate(ctx context.Context, id interface{}, data map[string]interface{}, ...) (*UpdateResult, error)
- func (eb *EnhancedBuilder) Update(id interface{}, data map[string]interface{}) error
- type EnhancedCRUDInterface
- type EnhancedFilter
- type ErrorHandlerInterface
- type EventInterface
- type ExecerInterface
- type Extension
- type ExtensionInterface
- type Filterdeprecated
- type FilterGroupdeprecated
- type FilterOperatordeprecated
- type FindOption
- type FindOptions
- type FindResult
- type GormAdapter
- func (a *GormAdapter) BatchInsert(ctx context.Context, table string, data []map[string]interface{}) error
- func (a *GormAdapter) BatchUpdate(ctx context.Context, table string, data []map[string]interface{}, ...) error
- func (a *GormAdapter) Begin() (TransactionInterface, error)
- func (a *GormAdapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
- func (a *GormAdapter) Close() error
- func (a *GormAdapter) Commit() error
- func (a *GormAdapter) Count(count *int64) error
- func (a *GormAdapter) Create(value interface{}) error
- func (a *GormAdapter) Delete(value interface{}, conds ...interface{}) error
- func (a *GormAdapter) Exec(query string, args ...interface{}) (sql.Result, error)
- func (a *GormAdapter) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (a *GormAdapter) Find(dest interface{}, conds ...interface{}) error
- func (a *GormAdapter) First(dest interface{}, conds ...interface{}) error
- func (a *GormAdapter) GetAdapterName() string
- func (a *GormAdapter) GetAdapterType() string
- func (a *GormAdapter) GetDB() *gorm.DB
- func (a *GormAdapter) GetDialect() string
- func (a *GormAdapter) GetInstance() interface{}
- func (a *GormAdapter) GetStats() ConnectionStats
- func (a *GormAdapter) Group(name string) *GormAdapter
- func (a *GormAdapter) Having(query interface{}, args ...interface{}) *GormAdapter
- func (a *GormAdapter) Joins(query string, args ...interface{}) *GormAdapter
- func (a *GormAdapter) Limit(limit int) *GormAdapter
- func (a *GormAdapter) Model(value interface{}) *GormAdapter
- func (a *GormAdapter) Not(query interface{}, args ...interface{}) *GormAdapter
- func (a *GormAdapter) Offset(offset int) *GormAdapter
- func (a *GormAdapter) Or(query interface{}, args ...interface{}) *GormAdapter
- func (a *GormAdapter) Order(value interface{}) *GormAdapter
- func (a *GormAdapter) Ping() error
- func (a *GormAdapter) PingContext(ctx context.Context) error
- func (a *GormAdapter) Pluck(column string, dest interface{}) error
- func (a *GormAdapter) Prepare(query string) (StatementInterface, error)
- func (a *GormAdapter) PrepareContext(ctx context.Context, query string) (StatementInterface, error)
- func (a *GormAdapter) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (a *GormAdapter) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (a *GormAdapter) QueryRow(query string, args ...interface{}) *sql.Row
- func (a *GormAdapter) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (a *GormAdapter) Rollback() error
- func (a *GormAdapter) Save(value interface{}) error
- func (a *GormAdapter) Scan(dest interface{}) error
- func (a *GormAdapter) Select(query interface{}, args ...interface{}) *GormAdapter
- func (a *GormAdapter) SupportsBulkInsert() bool
- func (a *GormAdapter) SupportsORM() bool
- func (a *GormAdapter) SupportsReturning() bool
- func (a *GormAdapter) SupportsUpsert() bool
- func (a *GormAdapter) Table(name string, args ...interface{}) *GormAdapter
- func (a *GormAdapter) Update(column string, value interface{}) error
- func (a *GormAdapter) Updates(values interface{}) error
- func (a *GormAdapter) Where(query interface{}, args ...interface{}) *GormAdapter
- type GormAssociationInterface
- type GormInterface
- type GormMigrationInterface
- type GormModelInterface
- type GormQueryInterface
- type GormResult
- type GormTransactionInterface
- type GormTxAdapterLegacy
- func (a *GormTxAdapterLegacy) Begin() (TransactionInterface, error)
- func (a *GormTxAdapterLegacy) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
- func (a *GormTxAdapterLegacy) Commit() error
- func (a *GormTxAdapterLegacy) Exec(query string, args ...interface{}) (sql.Result, error)
- func (a *GormTxAdapterLegacy) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (a *GormTxAdapterLegacy) GetTx() *gorm.DB
- func (a *GormTxAdapterLegacy) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (a *GormTxAdapterLegacy) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (a *GormTxAdapterLegacy) QueryRow(query string, args ...interface{}) *sql.Row
- func (a *GormTxAdapterLegacy) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (a *GormTxAdapterLegacy) Rollback() error
- type HookFunc
- type LengthRule
- type MapAny
- type MapString
- type MethodCompatibilityCheck
- type Metrics
- type Middleware
- type MigrationGuide
- type ModelInterface
- type MultiDatabaseInterface
- type MySQLDriverAdapter
- func (a *MySQLDriverAdapter) BuildLimit(offset, limit int64) string
- func (a *MySQLDriverAdapter) BuildUpsert(table string, data map[string]interface{}, conflictFields []string) (string, []interface{})
- func (a *MySQLDriverAdapter) ConvertScanValue(src interface{}) (interface{}, error)
- func (a *MySQLDriverAdapter) ConvertValue(value interface{}) (driver.Value, error)
- func (a *MySQLDriverAdapter) DriverName() string
- func (a *MySQLDriverAdapter) LastInsertId(result sql.Result) (int64, error)
- func (a *MySQLDriverAdapter) QuoteIdentifier(identifier string) string
- func (a *MySQLDriverAdapter) QuoteString(str string) string
- func (a *MySQLDriverAdapter) RowsAffected(result sql.Result) (int64, error)
- func (a *MySQLDriverAdapter) SupportsFeature(feature string) bool
- type OrderBydeprecated
- type OrderOption
- type PageBean
- type PerformanceInterface
- type PingInterface
- type PostgreSQLDriverAdapter
- func (a *PostgreSQLDriverAdapter) BuildLimit(offset, limit int64) string
- func (a *PostgreSQLDriverAdapter) BuildUpsert(table string, data map[string]interface{}, conflictFields []string) (string, []interface{})
- func (a *PostgreSQLDriverAdapter) ConvertScanValue(src interface{}) (interface{}, error)
- func (a *PostgreSQLDriverAdapter) ConvertValue(value interface{}) (driver.Value, error)
- func (a *PostgreSQLDriverAdapter) DriverName() string
- func (a *PostgreSQLDriverAdapter) LastInsertId(result sql.Result) (int64, error)
- func (a *PostgreSQLDriverAdapter) QuoteIdentifier(identifier string) string
- func (a *PostgreSQLDriverAdapter) QuoteString(str string) string
- func (a *PostgreSQLDriverAdapter) RowsAffected(result sql.Result) (int64, error)
- func (a *PostgreSQLDriverAdapter) SupportsFeature(feature string) bool
- type PreparedInterface
- type ProfileResult
- type QueryBuilderInterface
- type QueryLog
- type QueryLogInterface
- type QueryLogger
- type QueryerInterface
- type RelationInterface
- type RequiredRule
- type ResultInterface
- type SqlxAdapter
- func (a *SqlxAdapter) BatchInsert(ctx context.Context, table string, data []map[string]interface{}) error
- func (a *SqlxAdapter) BatchUpdate(ctx context.Context, table string, data []map[string]interface{}, ...) error
- func (a *SqlxAdapter) Begin() (TransactionInterface, error)
- func (a *SqlxAdapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
- func (a *SqlxAdapter) Close() error
- func (a *SqlxAdapter) Commit() error
- func (a *SqlxAdapter) Exec(query string, args ...interface{}) (sql.Result, error)
- func (a *SqlxAdapter) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (a *SqlxAdapter) Get(dest interface{}, query string, args ...interface{}) error
- func (a *SqlxAdapter) GetAdapterName() string
- func (a *SqlxAdapter) GetAdapterType() string
- func (a *SqlxAdapter) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (a *SqlxAdapter) GetDB() *sqlx.DB
- func (a *SqlxAdapter) GetDialect() string
- func (a *SqlxAdapter) GetInstance() interface{}
- func (a *SqlxAdapter) GetStats() ConnectionStats
- func (a *SqlxAdapter) NamedExec(query string, arg interface{}) (sql.Result, error)
- func (a *SqlxAdapter) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
- func (a *SqlxAdapter) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
- func (a *SqlxAdapter) NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
- func (a *SqlxAdapter) Ping() error
- func (a *SqlxAdapter) PingContext(ctx context.Context) error
- func (a *SqlxAdapter) Prepare(query string) (StatementInterface, error)
- func (a *SqlxAdapter) PrepareContext(ctx context.Context, query string) (StatementInterface, error)
- func (a *SqlxAdapter) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (a *SqlxAdapter) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (a *SqlxAdapter) QueryRow(query string, args ...interface{}) *sql.Row
- func (a *SqlxAdapter) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (a *SqlxAdapter) QueryRowx(query string, args ...interface{}) *sqlx.Row
- func (a *SqlxAdapter) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
- func (a *SqlxAdapter) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
- func (a *SqlxAdapter) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
- func (a *SqlxAdapter) Rollback() error
- func (a *SqlxAdapter) Select(dest interface{}, query string, args ...interface{}) error
- func (a *SqlxAdapter) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (a *SqlxAdapter) SupportsBulkInsert() bool
- func (a *SqlxAdapter) SupportsORM() bool
- func (a *SqlxAdapter) SupportsReturning() bool
- func (a *SqlxAdapter) SupportsUpsert() bool
- type SqlxGetInterface
- type SqlxInterface
- type SqlxNamedInterface
- type SqlxQueryInterface
- type SqlxSelectInterface
- type SqlxStmtAdapter
- func (a *SqlxStmtAdapter) Close() error
- func (a *SqlxStmtAdapter) Exec(args ...interface{}) (sql.Result, error)
- func (a *SqlxStmtAdapter) ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)
- func (a *SqlxStmtAdapter) Query(args ...interface{}) (*sql.Rows, error)
- func (a *SqlxStmtAdapter) QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error)
- func (a *SqlxStmtAdapter) QueryRow(args ...interface{}) *sql.Row
- func (a *SqlxStmtAdapter) QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
- type SqlxTxAdapter
- func (a *SqlxTxAdapter) Begin() (TransactionInterface, error)
- func (a *SqlxTxAdapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
- func (a *SqlxTxAdapter) Commit() error
- func (a *SqlxTxAdapter) Exec(query string, args ...interface{}) (sql.Result, error)
- func (a *SqlxTxAdapter) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (a *SqlxTxAdapter) Get(dest interface{}, query string, args ...interface{}) error
- func (a *SqlxTxAdapter) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- func (a *SqlxTxAdapter) GetTx() *sqlx.Tx
- func (a *SqlxTxAdapter) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (a *SqlxTxAdapter) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (a *SqlxTxAdapter) QueryRow(query string, args ...interface{}) *sql.Row
- func (a *SqlxTxAdapter) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (a *SqlxTxAdapter) Rollback() error
- func (a *SqlxTxAdapter) Select(dest interface{}, query string, args ...interface{}) error
- func (a *SqlxTxAdapter) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
- type StatementInterface
- type StringSlice
- type TransactionInterface
- type UniversalAdapterInterface
- type UpdateOptions
- type UpdateResult
- type V3Features
- type ValidationInterface
- type ValidationRule
Constants ¶
const ( QP_LT = "lt" // 小于 QP_GT = "gt" // 大于 QP_LTE = "lte" // 小于等于 QP_GTE = "gte" // 大于等于 QP_EQ = "eq" // 等于 QP_NEQ = "neq" // 不等于 QP_LK = "lk" // LIKE )
比较操作符
const ( QP_PD = "pd" // 降序(descending) QP_PA = "pa" // 升序(ascending) )
排序操作符
const ( QP_ORLK = "orlk" // OR LIKE QP_ORLT = "orlt" // OR LT QP_ORGT = "orgt" // OR GT )
或条件操作符
Variables ¶
This section is empty.
Functions ¶
func RegisterAdapter ¶
func RegisterAdapter(name string, creator func() DriverAdapterInterface)
RegisterAdapter 注册全局适配器
Types ¶
type AdapterCompatibilityCheck ¶
type AdapterCompatibilityCheck struct {
// contains filtered or unexported fields
}
AdapterCompatibilityCheck Adapter兼容性检查
func NewAdapterCompatibilityCheck ¶
func NewAdapterCompatibilityCheck(b *Builder) *AdapterCompatibilityCheck
NewAdapterCompatibilityCheck 创建Adapter兼容性检查
func (*AdapterCompatibilityCheck) Check ¶
func (acc *AdapterCompatibilityCheck) Check() error
Check 检查Adapter兼容性
func (*AdapterCompatibilityCheck) Name ¶
func (acc *AdapterCompatibilityCheck) Name() string
Name 返回检查名称
type AdapterFactory ¶
type AdapterFactory struct {
// contains filtered or unexported fields
}
AdapterFactory 适配器工厂
func (*AdapterFactory) Create ¶
func (f *AdapterFactory) Create(name string) (DriverAdapterInterface, error)
Create 创建适配器
func (*AdapterFactory) GetSupportedAdapters ¶
func (f *AdapterFactory) GetSupportedAdapters() []string
GetSupportedAdapters 获取支持的适配器列表
func (*AdapterFactory) Register ¶
func (f *AdapterFactory) Register(name string, creator func() DriverAdapterInterface)
Register 注册适配器
type AdvancedQueryInterface ¶
type AdvancedQueryInterface interface {
// 子查询
SubQuery(alias string) QueryBuilderInterface
WhereSubQuery(field, operator string, subQuery QueryBuilderInterface) QueryBuilderInterface
// 联合查询
Union(query QueryBuilderInterface) QueryBuilderInterface
UnionAll(query QueryBuilderInterface) QueryBuilderInterface
// 条件构建
When(condition bool, callback func(QueryBuilderInterface) QueryBuilderInterface) QueryBuilderInterface
Unless(condition bool, callback func(QueryBuilderInterface) QueryBuilderInterface) QueryBuilderInterface
// 作用域
Scope(callback func(QueryBuilderInterface) QueryBuilderInterface) QueryBuilderInterface
// 原始SQL
Raw(sql string, bindings ...interface{}) QueryBuilderInterface
SelectRaw(expression string, bindings ...interface{}) QueryBuilderInterface
WhereRaw(sql string, bindings ...interface{}) QueryBuilderInterface
OrWhereRaw(sql string, bindings ...interface{}) QueryBuilderInterface
HavingRaw(sql string, bindings ...interface{}) QueryBuilderInterface
OrderByRaw(sql string) QueryBuilderInterface
// 高级WHERE
WhereColumn(first, operator, second string) QueryBuilderInterface
OrWhereColumn(first, operator, second string) QueryBuilderInterface
WhereDate(column string, operator string, value interface{}) QueryBuilderInterface
WhereTime(column string, operator string, value interface{}) QueryBuilderInterface
WhereYear(column string, operator string, value interface{}) QueryBuilderInterface
WhereMonth(column string, operator string, value interface{}) QueryBuilderInterface
WhereDay(column string, operator string, value interface{}) QueryBuilderInterface
// JSON查询(MySQL/PostgreSQL)
WhereJson(column, path string, value interface{}) QueryBuilderInterface
WhereJsonContains(column string, value interface{}) QueryBuilderInterface
WhereJsonLength(column string, operator string, value int) QueryBuilderInterface
}
AdvancedQueryInterface 高级查询接口
type AdvancedQueryParam
deprecated
Deprecated: 使用 query.Param 替代 AdvancedQueryParam 被保留用于向后兼容,新代码应使用 query.Param
func NewAdvancedQueryParam
deprecated
func NewAdvancedQueryParam() *AdvancedQueryParam
Deprecated: 使用 query.NewParam() 替代 NewAdvancedQueryParam 创建高级查询参数 - 向后兼容适配器
type BackwardCompatibility ¶
type BackwardCompatibility struct {
// contains filtered or unexported fields
}
BackwardCompatibility 兼容性检查框架
func NewBackwardCompatibility ¶
func NewBackwardCompatibility() *BackwardCompatibility
NewBackwardCompatibility 创建兼容性检查
func (*BackwardCompatibility) CheckAll ¶
func (bc *BackwardCompatibility) CheckAll() []error
CheckAll 执行所有兼容性检查
func (*BackwardCompatibility) Register ¶
func (bc *BackwardCompatibility) Register(check CompatibilityCheck) *BackwardCompatibility
Register 注册兼容性检查
type BaseInfoFilter
deprecated
type BaseInfoFilter = query.BaseInfoFilter
Deprecated: 使用 query.BaseInfoFilter 替代
type BatchOperationInterface ¶
type BatchOperationInterface interface {
// 批量插入
InsertBatch(data []map[string]interface{}) (sql.Result, error)
InsertBatchSize(data []map[string]interface{}, batchSize int) error
// 批量更新
UpdateBatch(data []map[string]interface{}, primaryKey string) error
UpdateBatchSize(data []map[string]interface{}, primaryKey string, batchSize int) error
// 批量删除
DeleteBatch(conditions []map[string]interface{}) error
DeleteBatchSize(conditions []map[string]interface{}, batchSize int) error
// Upsert操作
Upsert(data interface{}, conflictFields []string, updateFields []string) error
UpsertBatch(data []map[string]interface{}, conflictFields []string, updateFields []string) error
// 批量查询
FindBatch(queries []QueryBuilderInterface) ([]interface{}, error)
FindBatchMaps(queries []QueryBuilderInterface) ([][]map[string]interface{}, error)
}
BatchOperationInterface 批量操作接口
type BuildMetrics ¶
type BuildMetrics struct {
// contains filtered or unexported fields
}
BuildMetrics 构建性能指标
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder 通用SQL查询构建器 (并发安全)
func (*Builder) BatchInsert ¶
BatchInsert 批量插入
func (*Builder) BatchUpdate ¶
BatchUpdate 批量更新
func (*Builder) GetAdapter ¶
func (b *Builder) GetAdapter() UniversalAdapterInterface
GetAdapter 获取适配器
func (*Builder) InsertGetID ¶
InsertGetID 插入并返回ID
func (*Builder) OrWhereRaw ¶
OrWhereRaw 原始OR WHERE
func (*Builder) OrderByDesc ¶
OrderByDesc 排序(降序)
func (*Builder) OrderByRaw ¶
OrderByRaw 原始ORDER BY
func (*Builder) Transaction ¶
Transaction 事务
func (*Builder) WhereBetween ¶
WhereBetween BETWEEN条件
func (*Builder) WhereNotIn ¶
WhereNotIn NOT IN条件
func (*Builder) WhereNotNull ¶
WhereNotNull NOT NULL条件
func (*Builder) WithContext ¶
WithContext 设置上下文 (并发安全)
type BuilderEnhancer ¶
type BuilderEnhancer struct {
// contains filtered or unexported fields
}
BuilderEnhancer Builder增强器 - 为现有Builder提供新功能映射
func NewBuilderEnhancer ¶
func NewBuilderEnhancer(b *Builder) *BuilderEnhancer
NewBuilderEnhancer 为Builder增加新功能
func (*BuilderEnhancer) AddMiddleware ¶
func (be *BuilderEnhancer) AddMiddleware(middlewares ...middleware.Middleware) *BuilderEnhancer
AddMiddleware 添加中间件
func (*BuilderEnhancer) GetBuilder ¶
func (be *BuilderEnhancer) GetBuilder() *Builder
GetBuilder 获取原始Builder
func (*BuilderEnhancer) GetCompiler ¶
func (be *BuilderEnhancer) GetCompiler() compiler.SQLCompiler
GetCompiler 获取SQL编译器
func (*BuilderEnhancer) GetExecutor ¶
func (be *BuilderEnhancer) GetExecutor() executor.Executor
GetExecutor 获取查询执行器
func (*BuilderEnhancer) GetMiddlewareChain ¶
func (be *BuilderEnhancer) GetMiddlewareChain() middleware.ExecutionChain
GetMiddlewareChain 获取middleware链
func (*BuilderEnhancer) GetPlanner ¶
func (be *BuilderEnhancer) GetPlanner() compiler.Planner
GetPlanner 获取查询计划器
type BuilderV2 ¶
type BuilderV2 struct {
// contains filtered or unexported fields
}
BuilderV2 改进的并发安全的Builder
func NewBuilderV2 ¶
NewBuilderV2 创建新的并发安全Builder
func (*BuilderV2) GetMetrics ¶
GetMetrics 获取性能指标 (线程安全)
type CacheInterface ¶
type CacheInterface interface {
// 查询缓存
Remember(key string, ttl int, callback func() (interface{}, error)) (interface{}, error)
RememberForever(key string, callback func() (interface{}, error)) (interface{}, error)
// 缓存管理
Forget(key string) error
Flush() error
// 缓存配置
CacheKey(key string) QueryBuilderInterface
CacheTTL(ttl int) QueryBuilderInterface
NoCache() QueryBuilderInterface
}
CacheInterface 缓存接口
type CompatibilityCheck ¶
CompatibilityCheck 兼容性检查接口
type ConnectionPoolInterface ¶
type ConnectionPoolInterface interface {
// 连接管理
GetConnection() (DatabaseInterface, error)
ReleaseConnection(conn DatabaseInterface) error
// 连接池配置
SetMaxOpenConns(max int) ConnectionPoolInterface
SetMaxIdleConns(max int) ConnectionPoolInterface
SetConnMaxLifetime(duration int) ConnectionPoolInterface
SetConnMaxIdleTime(duration int) ConnectionPoolInterface
// 连接池状态
Stats() sql.DBStats
// 健康检查
HealthCheck() error
// 关闭连接池
Close() error
}
ConnectionPoolInterface 连接池接口
type ConnectionStats ¶
type ConnectionStats struct {
OpenConnections int
InUse int
Idle int
WaitCount int64
WaitDuration time.Duration
MaxIdleClosed int64
MaxLifetimeClosed int64
}
ConnectionStats 连接统计信息
type CreateOptions ¶
CreateOptions 创建选项
type CreateResult ¶
CreateResult 创建结果
type DatabaseAdapterWrapper ¶
type DatabaseAdapterWrapper struct {
// contains filtered or unexported fields
}
DatabaseAdapterWrapper 包装旧的DatabaseInterface为新的UniversalAdapterInterface
func NewDatabaseAdapterWrapper ¶
func NewDatabaseAdapterWrapper(db DatabaseInterface, name string) *DatabaseAdapterWrapper
NewDatabaseAdapterWrapper 创建适配器包装器
func (*DatabaseAdapterWrapper) BatchInsert ¶
func (w *DatabaseAdapterWrapper) BatchInsert(ctx context.Context, table string, data []map[string]interface{}) error
批量操作的默认实现
func (*DatabaseAdapterWrapper) BatchUpdate ¶
func (*DatabaseAdapterWrapper) Begin ¶
func (w *DatabaseAdapterWrapper) Begin() (TransactionInterface, error)
func (*DatabaseAdapterWrapper) BeginTx ¶
func (w *DatabaseAdapterWrapper) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
func (*DatabaseAdapterWrapper) Close ¶
func (w *DatabaseAdapterWrapper) Close() error
func (*DatabaseAdapterWrapper) Commit ¶
func (w *DatabaseAdapterWrapper) Commit() error
func (*DatabaseAdapterWrapper) Exec ¶
func (w *DatabaseAdapterWrapper) Exec(query string, args ...interface{}) (sql.Result, error)
func (*DatabaseAdapterWrapper) ExecContext ¶
func (*DatabaseAdapterWrapper) GetAdapterName ¶
func (w *DatabaseAdapterWrapper) GetAdapterName() string
func (*DatabaseAdapterWrapper) GetAdapterType ¶
func (w *DatabaseAdapterWrapper) GetAdapterType() string
func (*DatabaseAdapterWrapper) GetDialect ¶
func (w *DatabaseAdapterWrapper) GetDialect() string
func (*DatabaseAdapterWrapper) GetInstance ¶
func (w *DatabaseAdapterWrapper) GetInstance() interface{}
func (*DatabaseAdapterWrapper) GetStats ¶
func (w *DatabaseAdapterWrapper) GetStats() ConnectionStats
func (*DatabaseAdapterWrapper) Ping ¶
func (w *DatabaseAdapterWrapper) Ping() error
func (*DatabaseAdapterWrapper) PingContext ¶
func (w *DatabaseAdapterWrapper) PingContext(ctx context.Context) error
func (*DatabaseAdapterWrapper) Prepare ¶
func (w *DatabaseAdapterWrapper) Prepare(query string) (StatementInterface, error)
func (*DatabaseAdapterWrapper) PrepareContext ¶
func (w *DatabaseAdapterWrapper) PrepareContext(ctx context.Context, query string) (StatementInterface, error)
func (*DatabaseAdapterWrapper) Query ¶
func (w *DatabaseAdapterWrapper) Query(query string, args ...interface{}) (*sql.Rows, error)
委托给底层DatabaseInterface
func (*DatabaseAdapterWrapper) QueryContext ¶
func (*DatabaseAdapterWrapper) QueryRow ¶
func (w *DatabaseAdapterWrapper) QueryRow(query string, args ...interface{}) *sql.Row
func (*DatabaseAdapterWrapper) QueryRowContext ¶
func (*DatabaseAdapterWrapper) Rollback ¶
func (w *DatabaseAdapterWrapper) Rollback() error
func (*DatabaseAdapterWrapper) SupportsBulkInsert ¶
func (w *DatabaseAdapterWrapper) SupportsBulkInsert() bool
func (*DatabaseAdapterWrapper) SupportsORM ¶
func (w *DatabaseAdapterWrapper) SupportsORM() bool
func (*DatabaseAdapterWrapper) SupportsReturning ¶
func (w *DatabaseAdapterWrapper) SupportsReturning() bool
func (*DatabaseAdapterWrapper) SupportsUpsert ¶
func (w *DatabaseAdapterWrapper) SupportsUpsert() bool
type DatabaseInterface ¶
type DatabaseInterface interface {
QueryerInterface
ExecerInterface
TransactionInterface
PreparedInterface
PingInterface
CloseInterface
}
DatabaseInterface 数据库核心接口
type DeleteOptions ¶
DeleteOptions 删除选项
type DeleteResult ¶
DeleteResult 删除结果
type DriverAdapterInterface ¶
type DriverAdapterInterface interface {
// 驱动信息
DriverName() string
SupportsFeature(feature string) bool
// SQL方言
QuoteIdentifier(identifier string) string
QuoteString(str string) string
BuildLimit(offset, limit int64) string
BuildUpsert(table string, data map[string]interface{}, conflictFields []string) (string, []interface{})
// 数据类型转换
ConvertValue(value interface{}) (driver.Value, error)
ConvertScanValue(src interface{}) (interface{}, error)
// 特殊操作
LastInsertId(result sql.Result) (int64, error)
RowsAffected(result sql.Result) (int64, error)
}
DriverAdapterInterface 驱动适配器接口
func CreateAdapter ¶
func CreateAdapter(name string) (DriverAdapterInterface, error)
CreateAdapter 创建适配器实例
type EnhancedBuilder ¶
type EnhancedBuilder struct {
*Builder
// contains filtered or unexported fields
}
EnhancedBuilder 增强的SQL构建器
func NewEnhanced ¶
func NewEnhanced(dbInstance interface{}) (*EnhancedBuilder, error)
NewEnhanced 创建增强构建器
func NewSimple ¶
func NewSimple(db interface{}, tableName string) (*EnhancedBuilder, error)
NewSimple 创建一个简单易用的CRUD操作器
func (*EnhancedBuilder) Add ¶
func (eb *EnhancedBuilder) Add(data map[string]interface{}) error
Add 添加数据 - 一行代码搞定
func (*EnhancedBuilder) AddAuditFields ¶
func (eb *EnhancedBuilder) AddAuditFields(fields ...string) *EnhancedBuilder
AddAuditFields 添加审计字段
func (*EnhancedBuilder) AddHook ¶
func (eb *EnhancedBuilder) AddHook(event string, hook HookFunc) *EnhancedBuilder
AddHook 添加钩子函数
func (*EnhancedBuilder) AddValidation ¶
func (eb *EnhancedBuilder) AddValidation(field string, rule ValidationRule) *EnhancedBuilder
AddValidation 添加字段验证规则
func (*EnhancedBuilder) BatchUpsert ¶
func (eb *EnhancedBuilder) BatchUpsert(ctx context.Context, data []map[string]interface{}, conflictFields []string) error
BatchUpsert 批量Upsert
func (*EnhancedBuilder) Create ¶
func (eb *EnhancedBuilder) Create(data map[string]interface{}) error
Create 创建数据(Add的别名)
func (*EnhancedBuilder) Delete ¶
func (eb *EnhancedBuilder) Delete(id interface{}) error
Delete 删除数据 - 按ID删除(软删除)
func (*EnhancedBuilder) EnableSoftDelete ¶
func (eb *EnhancedBuilder) EnableSoftDelete(enable bool) *EnhancedBuilder
EnableSoftDelete 启用/禁用软删除
func (*EnhancedBuilder) Find ¶
func (eb *EnhancedBuilder) Find(page, pageSize int64) ([]map[string]interface{}, error)
Find 查找数据(List的别名)
func (*EnhancedBuilder) Get ¶
func (eb *EnhancedBuilder) Get(id interface{}) (map[string]interface{}, error)
Get 获取单条数据 - 按ID查询
func (*EnhancedBuilder) List ¶
func (eb *EnhancedBuilder) List(page, pageSize int64) ([]map[string]interface{}, error)
List 获取数据列表 - 支持分页
func (*EnhancedBuilder) Read ¶
func (eb *EnhancedBuilder) Read(id interface{}) (map[string]interface{}, error)
Read 读取数据(Get的别名)
func (*EnhancedBuilder) Save ¶
func (eb *EnhancedBuilder) Save(data map[string]interface{}) error
Save 保存数据(智能判断是新增还是更新)
func (*EnhancedBuilder) Search ¶
func (eb *EnhancedBuilder) Search(field, keyword string, page, pageSize int64) ([]map[string]interface{}, error)
Search 简单搜索 - 模糊查询
func (*EnhancedBuilder) SmartCreate ¶
func (eb *EnhancedBuilder) SmartCreate(ctx context.Context, data map[string]interface{}, options *CreateOptions) (*CreateResult, error)
SmartCreate 智能创建
func (*EnhancedBuilder) SmartDelete ¶
func (eb *EnhancedBuilder) SmartDelete(ctx context.Context, id interface{}, options *DeleteOptions) (*DeleteResult, error)
SmartDelete 智能删除
func (*EnhancedBuilder) SmartFind ¶
func (eb *EnhancedBuilder) SmartFind(ctx context.Context, options *FindOptions) (*FindResult, error)
SmartFind 智能查询
func (*EnhancedBuilder) SmartUpdate ¶
func (eb *EnhancedBuilder) SmartUpdate(ctx context.Context, id interface{}, data map[string]interface{}, options *UpdateOptions) (*UpdateResult, error)
SmartUpdate 智能更新
func (*EnhancedBuilder) Update ¶
func (eb *EnhancedBuilder) Update(id interface{}, data map[string]interface{}) error
Update 更新数据 - 按ID更新
type EnhancedCRUDInterface ¶
type EnhancedCRUDInterface interface {
// 智能创建 - 带验证和钩子
SmartCreate(ctx context.Context, data map[string]interface{}, options *CreateOptions) (*CreateResult, error)
// 智能更新 - 带乐观锁
SmartUpdate(ctx context.Context, id interface{}, data map[string]interface{}, options *UpdateOptions) (*UpdateResult, error)
// 智能删除 - 软删除优先
SmartDelete(ctx context.Context, id interface{}, options *DeleteOptions) (*DeleteResult, error)
// 智能查询 - 带缓存和分页
SmartFind(ctx context.Context, options *FindOptions) (*FindResult, error)
// 批量Upsert
BatchUpsert(ctx context.Context, data []map[string]interface{}, conflictFields []string) error
}
EnhancedCRUDInterface 增强CRUD接口
type EnhancedFilter ¶
EnhancedFilter 增强过滤器
type ErrorHandlerInterface ¶
type ErrorHandlerInterface interface {
// 错误处理
OnError(callback func(error) error) QueryBuilderInterface
IgnoreErrors() QueryBuilderInterface
FailOnError() QueryBuilderInterface
// 错误重试
Retry(maxAttempts int) QueryBuilderInterface
RetryWhen(condition func(error) bool, maxAttempts int) QueryBuilderInterface
// 错误转换
TransformError(transformer func(error) error) QueryBuilderInterface
// 错误记录
LogErrors(enable bool) QueryBuilderInterface
}
ErrorHandlerInterface 错误处理接口
type EventInterface ¶
type EventInterface interface {
// 查询事件
BeforeQuery(callback func(sql string, bindings []interface{})) QueryBuilderInterface
AfterQuery(callback func(sql string, bindings []interface{}, result interface{})) QueryBuilderInterface
// 执行事件
BeforeExec(callback func(sql string, bindings []interface{})) QueryBuilderInterface
AfterExec(callback func(sql string, bindings []interface{}, result sql.Result)) QueryBuilderInterface
// 事务事件
BeforeTransaction(callback func()) QueryBuilderInterface
AfterTransaction(callback func(committed bool)) QueryBuilderInterface
}
EventInterface 事件接口
type ExecerInterface ¶
type ExecerInterface interface {
Exec(query string, args ...interface{}) (sql.Result, error)
ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}
ExecerInterface 执行接口
type Extension ¶
type Extension interface {
Name() string
Install(builder QueryBuilderInterface) error
Uninstall(builder QueryBuilderInterface) error
}
Extension 扩展接口
type ExtensionInterface ¶
type ExtensionInterface interface {
// 扩展注册
RegisterExtension(name string, extension Extension) error
GetExtension(name string) (Extension, bool)
RemoveExtension(name string) bool
// 中间件
UseMiddleware(middleware ...Middleware) QueryBuilderInterface
// 宏定义
Macro(name string, callback interface{}) error
CallMacro(name string, args ...interface{}) (interface{}, error)
}
ExtensionInterface 扩展接口
type FilterGroup
deprecated
type FilterGroup = query.FilterGroup
Deprecated: 使用 query.FilterGroup 替代
type FilterOperator
deprecated
Deprecated: 使用 query.Operator 替代
const ( OP_EQ FilterOperator = query.OP_EQ // 等于 OP_NEQ FilterOperator = query.OP_NEQ // 不等于 OP_GT FilterOperator = query.OP_GT // 大于 OP_GTE FilterOperator = query.OP_GTE // 大于等于 OP_LT FilterOperator = query.OP_LT // 小于 OP_LTE FilterOperator = query.OP_LTE // 小于等于 OP_LIKE FilterOperator = query.OP_LIKE // 模糊匹配 OP_IN FilterOperator = query.OP_IN // 包含 OP_BETWEEN FilterOperator = query.OP_BETWEEN // 范围 OP_IS_NULL FilterOperator = query.OP_IS_NULL // 为空 OP_FIND_IN_SET FilterOperator = query.OP_FIND_IN_SET // MySQL FIND_IN_SET )
Deprecated: 使用 query.OP_* 常量替代
type FindOption ¶
type FindOption struct {
BusinessId string // 业务ID
ShopId string // 店铺ID
TablePrefix string // 表名前缀
ExcludeField bool // 是否排除字段
ExcludeFields []string // 排除字段列表
IncludeFields []string // 包含字段列表
NoCache bool // 是否不使用缓存
CacheTTL time.Duration // 缓存过期时间
}
FindOption 查询选项 - 借鉴go-core设计
func (*FindOption) WithBusinessId ¶
func (fo *FindOption) WithBusinessId(id string) *FindOption
WithBusinessId 设置业务ID
func (*FindOption) WithCacheTTL ¶
func (fo *FindOption) WithCacheTTL(ttl time.Duration) *FindOption
WithCacheTTL 设置缓存TTL
func (*FindOption) WithShopId ¶
func (fo *FindOption) WithShopId(id string) *FindOption
WithShopId 设置店铺ID
func (*FindOption) WithTablePrefix ¶
func (fo *FindOption) WithTablePrefix(prefix string) *FindOption
WithTablePrefix 设置表名前缀
type FindOptions ¶
type FindOptions struct {
Filters []*EnhancedFilter
Orders []*OrderOption
Limit int64
Offset int64
IncludeDeleted bool
CountTotal bool
}
FindOptions 查询选项
type FindResult ¶
FindResult 查询结果
type GormAdapter ¶
type GormAdapter struct {
// contains filtered or unexported fields
}
GormAdapter GORM数据库适配器 - 实现通用适配器接口
func NewGormTxAdapter ¶
func NewGormTxAdapter(tx *gorm.DB) *GormAdapter
NewGormTxAdapter 创建GORM事务适配器
func (*GormAdapter) BatchInsert ¶
func (a *GormAdapter) BatchInsert(ctx context.Context, table string, data []map[string]interface{}) error
BatchInsert 批量插入
func (*GormAdapter) BatchUpdate ¶
func (a *GormAdapter) BatchUpdate(ctx context.Context, table string, data []map[string]interface{}, whereColumns []string) error
BatchUpdate 批量更新
func (*GormAdapter) Begin ¶
func (a *GormAdapter) Begin() (TransactionInterface, error)
func (*GormAdapter) BeginTx ¶
func (a *GormAdapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
func (*GormAdapter) Close ¶
func (a *GormAdapter) Close() error
func (*GormAdapter) Commit ¶
func (a *GormAdapter) Commit() error
func (*GormAdapter) Count ¶
func (a *GormAdapter) Count(count *int64) error
func (*GormAdapter) Create ¶
func (a *GormAdapter) Create(value interface{}) error
func (*GormAdapter) Delete ¶
func (a *GormAdapter) Delete(value interface{}, conds ...interface{}) error
func (*GormAdapter) Exec ¶
func (a *GormAdapter) Exec(query string, args ...interface{}) (sql.Result, error)
func (*GormAdapter) ExecContext ¶
func (*GormAdapter) Find ¶
func (a *GormAdapter) Find(dest interface{}, conds ...interface{}) error
func (*GormAdapter) First ¶
func (a *GormAdapter) First(dest interface{}, conds ...interface{}) error
func (*GormAdapter) GetAdapterName ¶
func (a *GormAdapter) GetAdapterName() string
GetAdapterName 获取适配器名称
func (*GormAdapter) GetAdapterType ¶
func (a *GormAdapter) GetAdapterType() string
GetAdapterType 获取适配器类型
func (*GormAdapter) GetDB ¶
func (a *GormAdapter) GetDB() *gorm.DB
func (*GormAdapter) GetInstance ¶
func (a *GormAdapter) GetInstance() interface{}
GetInstance 获取底层GORM实例
func (*GormAdapter) Group ¶
func (a *GormAdapter) Group(name string) *GormAdapter
func (*GormAdapter) Having ¶
func (a *GormAdapter) Having(query interface{}, args ...interface{}) *GormAdapter
func (*GormAdapter) Joins ¶
func (a *GormAdapter) Joins(query string, args ...interface{}) *GormAdapter
func (*GormAdapter) Limit ¶
func (a *GormAdapter) Limit(limit int) *GormAdapter
func (*GormAdapter) Not ¶
func (a *GormAdapter) Not(query interface{}, args ...interface{}) *GormAdapter
func (*GormAdapter) Offset ¶
func (a *GormAdapter) Offset(offset int) *GormAdapter
func (*GormAdapter) Or ¶
func (a *GormAdapter) Or(query interface{}, args ...interface{}) *GormAdapter
func (*GormAdapter) Order ¶
func (a *GormAdapter) Order(value interface{}) *GormAdapter
func (*GormAdapter) Ping ¶
func (a *GormAdapter) Ping() error
func (*GormAdapter) PingContext ¶
func (a *GormAdapter) PingContext(ctx context.Context) error
func (*GormAdapter) Pluck ¶
func (a *GormAdapter) Pluck(column string, dest interface{}) error
func (*GormAdapter) Prepare ¶
func (a *GormAdapter) Prepare(query string) (StatementInterface, error)
func (*GormAdapter) PrepareContext ¶
func (a *GormAdapter) PrepareContext(ctx context.Context, query string) (StatementInterface, error)
func (*GormAdapter) Query ¶
func (a *GormAdapter) Query(query string, args ...interface{}) (*sql.Rows, error)
基本数据库操作
func (*GormAdapter) QueryContext ¶
func (*GormAdapter) QueryRow ¶
func (a *GormAdapter) QueryRow(query string, args ...interface{}) *sql.Row
func (*GormAdapter) QueryRowContext ¶
func (*GormAdapter) Rollback ¶
func (a *GormAdapter) Rollback() error
func (*GormAdapter) Save ¶
func (a *GormAdapter) Save(value interface{}) error
func (*GormAdapter) Scan ¶
func (a *GormAdapter) Scan(dest interface{}) error
func (*GormAdapter) Select ¶
func (a *GormAdapter) Select(query interface{}, args ...interface{}) *GormAdapter
func (*GormAdapter) SupportsBulkInsert ¶
func (a *GormAdapter) SupportsBulkInsert() bool
SupportsBulkInsert 批量插入支持检测
func (*GormAdapter) SupportsReturning ¶
func (a *GormAdapter) SupportsReturning() bool
SupportsReturning RETURNING语句支持检测
func (*GormAdapter) SupportsUpsert ¶
func (a *GormAdapter) SupportsUpsert() bool
SupportsUpsert Upsert支持检测
func (*GormAdapter) Table ¶
func (a *GormAdapter) Table(name string, args ...interface{}) *GormAdapter
func (*GormAdapter) Update ¶
func (a *GormAdapter) Update(column string, value interface{}) error
func (*GormAdapter) Updates ¶
func (a *GormAdapter) Updates(values interface{}) error
func (*GormAdapter) Where ¶
func (a *GormAdapter) Where(query interface{}, args ...interface{}) *GormAdapter
type GormAssociationInterface ¶
type GormAssociationInterface interface {
Association(column string) *gorm.Association
}
GormAssociationInterface GORM关联接口
type GormInterface ¶
type GormInterface interface {
GormQueryInterface
GormTransactionInterface
GormMigrationInterface
GormModelInterface
GormAssociationInterface
}
GormInterface GORM特定接口
type GormMigrationInterface ¶
type GormMigrationInterface interface {
AutoMigrate(dst ...interface{}) error
Migrator() gorm.Migrator
}
GormMigrationInterface GORM迁移接口
type GormModelInterface ¶
type GormModelInterface interface {
Create(value interface{}) GormInterface
CreateInBatches(value interface{}, batchSize int) GormInterface
Save(value interface{}) GormInterface
First(dest interface{}, conds ...interface{}) GormInterface
Take(dest interface{}, conds ...interface{}) GormInterface
Last(dest interface{}, conds ...interface{}) GormInterface
Find(dest interface{}, conds ...interface{}) GormInterface
FindInBatches(dest interface{}, batchSize int, fc func(tx GormInterface, batch int) error) error
FirstOrInit(dest interface{}, conds ...interface{}) GormInterface
FirstOrCreate(dest interface{}, conds ...interface{}) GormInterface
Update(column string, value interface{}) GormInterface
Updates(values interface{}) GormInterface
UpdateColumn(column string, value interface{}) GormInterface
UpdateColumns(values interface{}) GormInterface
Delete(value interface{}, conds ...interface{}) GormInterface
Count(count *int64) GormInterface
Row() *sql.Row
Rows() (*sql.Rows, error)
Scan(dest interface{}) GormInterface
Pluck(column string, dest interface{}) GormInterface
ScanRows(rows *sql.Rows, dest interface{}) error
}
GormModelInterface GORM模型操作接口
type GormQueryInterface ¶
type GormQueryInterface interface {
Model(value interface{}) GormInterface
Table(name string, args ...interface{}) GormInterface
Distinct(args ...interface{}) GormInterface
Select(query interface{}, args ...interface{}) GormInterface
Omit(columns ...string) GormInterface
Where(query interface{}, args ...interface{}) GormInterface
Not(query interface{}, args ...interface{}) GormInterface
Or(query interface{}, args ...interface{}) GormInterface
Joins(query string, args ...interface{}) GormInterface
Group(name string) GormInterface
Having(query interface{}, args ...interface{}) GormInterface
Order(value interface{}) GormInterface
Limit(limit int) GormInterface
Offset(offset int) GormInterface
Scopes(funcs ...func(GormInterface) GormInterface) GormInterface
}
GormQueryInterface GORM查询接口
type GormResult ¶
type GormResult struct {
// contains filtered or unexported fields
}
GormResult GORM结果适配器
func (*GormResult) LastInsertId ¶
func (r *GormResult) LastInsertId() (int64, error)
func (*GormResult) RowsAffected ¶
func (r *GormResult) RowsAffected() (int64, error)
type GormTransactionInterface ¶
type GormTransactionInterface interface {
Transaction(fc func(tx GormInterface) error, opts ...*sql.TxOptions) error
Begin(opts ...*sql.TxOptions) GormInterface
Commit() GormInterface
Rollback() GormInterface
SavePoint(name string) GormInterface
RollbackTo(name string) GormInterface
}
GormTransactionInterface GORM事务接口
type GormTxAdapterLegacy ¶
type GormTxAdapterLegacy struct {
// contains filtered or unexported fields
}
GormTxAdapterLegacy GORM事务适配器 (保留兼容性)
func NewGormTxAdapterLegacy ¶
func NewGormTxAdapterLegacy(tx *gorm.DB) *GormTxAdapterLegacy
NewGormTxAdapterLegacy 创建GORM事务适配器 (兼容性)
func (*GormTxAdapterLegacy) Begin ¶
func (a *GormTxAdapterLegacy) Begin() (TransactionInterface, error)
func (*GormTxAdapterLegacy) BeginTx ¶
func (a *GormTxAdapterLegacy) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
func (*GormTxAdapterLegacy) Commit ¶
func (a *GormTxAdapterLegacy) Commit() error
func (*GormTxAdapterLegacy) Exec ¶
func (a *GormTxAdapterLegacy) Exec(query string, args ...interface{}) (sql.Result, error)
func (*GormTxAdapterLegacy) ExecContext ¶
func (*GormTxAdapterLegacy) GetTx ¶
func (a *GormTxAdapterLegacy) GetTx() *gorm.DB
func (*GormTxAdapterLegacy) Query ¶
func (a *GormTxAdapterLegacy) Query(query string, args ...interface{}) (*sql.Rows, error)
func (*GormTxAdapterLegacy) QueryContext ¶
func (*GormTxAdapterLegacy) QueryRow ¶
func (a *GormTxAdapterLegacy) QueryRow(query string, args ...interface{}) *sql.Row
func (*GormTxAdapterLegacy) QueryRowContext ¶
func (*GormTxAdapterLegacy) Rollback ¶
func (a *GormTxAdapterLegacy) Rollback() error
type LengthRule ¶
LengthRule 长度验证
func (LengthRule) Validate ¶
func (r LengthRule) Validate(value interface{}) error
type MethodCompatibilityCheck ¶
type MethodCompatibilityCheck struct {
// contains filtered or unexported fields
}
MethodCompatibilityCheck 方法兼容性检查
func NewMethodCompatibilityCheck ¶
func NewMethodCompatibilityCheck(b *Builder) *MethodCompatibilityCheck
NewMethodCompatibilityCheck 创建方法兼容性检查
func (*MethodCompatibilityCheck) Check ¶
func (mcc *MethodCompatibilityCheck) Check() error
Check 检查方法兼容性
func (*MethodCompatibilityCheck) Name ¶
func (mcc *MethodCompatibilityCheck) Name() string
Name 返回检查名称
type Metrics ¶
type Metrics struct {
TotalQueries int64 `json:"total_queries"`
TotalTime float64 `json:"total_time"`
AverageTime float64 `json:"average_time"`
SlowestQuery QueryLog `json:"slowest_query"`
FastestQuery QueryLog `json:"fastest_query"`
QueriesPerSecond float64 `json:"queries_per_second"`
ErrorCount int64 `json:"error_count"`
CacheHitRate float64 `json:"cache_hit_rate"`
}
Metrics 性能指标
type Middleware ¶
Middleware 中间件接口
type MigrationGuide ¶
type MigrationGuide struct {
// contains filtered or unexported fields
}
MigrationGuide v2->v3迁移指南
func NewMigrationGuide ¶
func NewMigrationGuide(b *Builder) *MigrationGuide
NewMigrationGuide 创建迁移指南
func (*MigrationGuide) MigrateToV3 ¶
func (mg *MigrationGuide) MigrateToV3() *BuilderEnhancer
MigrateToV3 迁移到v3
type ModelInterface ¶
type ModelInterface interface {
// 模型绑定
Model(model interface{}) QueryBuilderInterface
With(relations ...string) QueryBuilderInterface
Without(relations ...string) QueryBuilderInterface
// 软删除
WithTrashed() QueryBuilderInterface
OnlyTrashed() QueryBuilderInterface
WithoutTrashed() QueryBuilderInterface
Restore() error
ForceDelete() error
// 时间戳
Touch() error
TouchQuietly() error
// 属性访问
GetAttribute(key string) interface{}
SetAttribute(key string, value interface{}) ModelInterface
GetAttributes() map[string]interface{}
SetAttributes(attributes map[string]interface{}) ModelInterface
// 模型状态
IsDirty(attributes ...string) bool
IsClean(attributes ...string) bool
GetDirty() map[string]interface{}
GetOriginal(key ...string) interface{}
// 序列化
ToJSON() ([]byte, error)
ToMap() map[string]interface{}
ToArray() []interface{}
}
ModelInterface 模型接口
type MultiDatabaseInterface ¶
type MultiDatabaseInterface interface {
// 数据库切换
Connection(name string) QueryBuilderInterface
On(connection string) QueryBuilderInterface
// 配置管理
AddConnection(name string, config interface{}) error
RemoveConnection(name string) error
GetConnectionNames() []string
// 默认连接
SetDefaultConnection(name string) MultiDatabaseInterface
GetDefaultConnection() string
// 连接测试
TestConnection(name string) error
TestAllConnections() map[string]error
}
MultiDatabaseInterface 多数据库接口
type MySQLDriverAdapter ¶
type MySQLDriverAdapter struct{}
MySQLDriverAdapter MySQL驱动适配器
func NewMySQLDriverAdapter ¶
func NewMySQLDriverAdapter() *MySQLDriverAdapter
func (*MySQLDriverAdapter) BuildLimit ¶
func (a *MySQLDriverAdapter) BuildLimit(offset, limit int64) string
func (*MySQLDriverAdapter) BuildUpsert ¶
func (a *MySQLDriverAdapter) BuildUpsert(table string, data map[string]interface{}, conflictFields []string) (string, []interface{})
func (*MySQLDriverAdapter) ConvertScanValue ¶
func (a *MySQLDriverAdapter) ConvertScanValue(src interface{}) (interface{}, error)
func (*MySQLDriverAdapter) ConvertValue ¶
func (a *MySQLDriverAdapter) ConvertValue(value interface{}) (driver.Value, error)
func (*MySQLDriverAdapter) DriverName ¶
func (a *MySQLDriverAdapter) DriverName() string
func (*MySQLDriverAdapter) LastInsertId ¶
func (a *MySQLDriverAdapter) LastInsertId(result sql.Result) (int64, error)
func (*MySQLDriverAdapter) QuoteIdentifier ¶
func (a *MySQLDriverAdapter) QuoteIdentifier(identifier string) string
func (*MySQLDriverAdapter) QuoteString ¶
func (a *MySQLDriverAdapter) QuoteString(str string) string
func (*MySQLDriverAdapter) RowsAffected ¶
func (a *MySQLDriverAdapter) RowsAffected(result sql.Result) (int64, error)
func (*MySQLDriverAdapter) SupportsFeature ¶
func (a *MySQLDriverAdapter) SupportsFeature(feature string) bool
type OrderOption ¶
OrderOption 排序选项
type PageBean ¶
type PageBean struct {
Page int `json:"page"` // 当前页码
PageSize int `json:"page_size"` // 每页数量
Total int64 `json:"total"` // 总数
Pages int `json:"pages"` // 总页数
Rows interface{} `json:"rows"` // 数据行
}
PageBean 分页响应 - 借鉴go-core设计
type PerformanceInterface ¶
type PerformanceInterface interface {
// 查询分析
Explain() ([]map[string]interface{}, error)
Profile() (ProfileResult, error)
// 性能指标
GetMetrics() Metrics
ResetMetrics() PerformanceInterface
// 慢查询检测
SlowQueryThreshold(threshold float64) PerformanceInterface
OnSlowQuery(callback func(QueryLog)) PerformanceInterface
}
PerformanceInterface 性能监控接口
type PingInterface ¶
PingInterface Ping接口
type PostgreSQLDriverAdapter ¶
type PostgreSQLDriverAdapter struct{}
PostgreSQLDriverAdapter PostgreSQL驱动适配器
func NewPostgreSQLDriverAdapter ¶
func NewPostgreSQLDriverAdapter() *PostgreSQLDriverAdapter
func (*PostgreSQLDriverAdapter) BuildLimit ¶
func (a *PostgreSQLDriverAdapter) BuildLimit(offset, limit int64) string
func (*PostgreSQLDriverAdapter) BuildUpsert ¶
func (a *PostgreSQLDriverAdapter) BuildUpsert(table string, data map[string]interface{}, conflictFields []string) (string, []interface{})
func (*PostgreSQLDriverAdapter) ConvertScanValue ¶
func (a *PostgreSQLDriverAdapter) ConvertScanValue(src interface{}) (interface{}, error)
func (*PostgreSQLDriverAdapter) ConvertValue ¶
func (a *PostgreSQLDriverAdapter) ConvertValue(value interface{}) (driver.Value, error)
func (*PostgreSQLDriverAdapter) DriverName ¶
func (a *PostgreSQLDriverAdapter) DriverName() string
func (*PostgreSQLDriverAdapter) LastInsertId ¶
func (a *PostgreSQLDriverAdapter) LastInsertId(result sql.Result) (int64, error)
func (*PostgreSQLDriverAdapter) QuoteIdentifier ¶
func (a *PostgreSQLDriverAdapter) QuoteIdentifier(identifier string) string
func (*PostgreSQLDriverAdapter) QuoteString ¶
func (a *PostgreSQLDriverAdapter) QuoteString(str string) string
func (*PostgreSQLDriverAdapter) RowsAffected ¶
func (a *PostgreSQLDriverAdapter) RowsAffected(result sql.Result) (int64, error)
func (*PostgreSQLDriverAdapter) SupportsFeature ¶
func (a *PostgreSQLDriverAdapter) SupportsFeature(feature string) bool
type PreparedInterface ¶
type PreparedInterface interface {
Prepare(query string) (StatementInterface, error)
PrepareContext(ctx context.Context, query string) (StatementInterface, error)
}
PreparedInterface 预处理语句接口
type ProfileResult ¶
type ProfileResult struct {
QueryTime float64 `json:"query_time"`
PrepareTime float64 `json:"prepare_time"`
ExecuteTime float64 `json:"execute_time"`
RowsAffected int64 `json:"rows_affected"`
RowsReturned int64 `json:"rows_returned"`
Explain []map[string]interface{} `json:"explain"`
}
ProfileResult 性能分析结果
type QueryBuilderInterface ¶
type QueryBuilderInterface interface {
// 基本查询方法
Select(fields ...interface{}) QueryBuilderInterface
Table(table interface{}) QueryBuilderInterface
Where(args ...interface{}) QueryBuilderInterface
OrWhere(args ...interface{}) QueryBuilderInterface
WhereIn(field string, values []interface{}) QueryBuilderInterface
WhereNotIn(field string, values []interface{}) QueryBuilderInterface
WhereBetween(field string, start, end interface{}) QueryBuilderInterface
WhereNull(field string) QueryBuilderInterface
WhereNotNull(field string) QueryBuilderInterface
WhereLike(field, pattern string) QueryBuilderInterface
WhereExists(subQuery QueryBuilderInterface) QueryBuilderInterface
// JOIN操作
Join(table, condition string) QueryBuilderInterface
LeftJoin(table, condition string) QueryBuilderInterface
RightJoin(table, condition string) QueryBuilderInterface
InnerJoin(table, condition string) QueryBuilderInterface
// 分组和排序
GroupBy(fields ...string) QueryBuilderInterface
Having(args ...interface{}) QueryBuilderInterface
OrderBy(field string, direction ...string) QueryBuilderInterface
OrderByDesc(field string) QueryBuilderInterface
// 分页和限制
Limit(limit int64) QueryBuilderInterface
Offset(offset int64) QueryBuilderInterface
Page(page, pageSize int64) QueryBuilderInterface
// 插入、更新、删除
Insert(data interface{}) QueryBuilderInterface
Update(data interface{}) QueryBuilderInterface
Delete() QueryBuilderInterface
// 执行方法
ToSQL() (string, []interface{})
Exec() (sql.Result, error)
Get(dest interface{}) error
Find(dest interface{}) error
Count(column ...string) (int64, error)
Exists() (bool, error)
// 工具方法
Clone() QueryBuilderInterface
Debug(enable ...bool) QueryBuilderInterface
}
QueryBuilderInterface 查询构建器核心接口
type QueryLog ¶
type QueryLog struct {
SQL string `json:"sql"`
Bindings []interface{} `json:"bindings"`
Time float64 `json:"time"`
Context string `json:"context,omitempty"`
}
QueryLog 查询日志结构
type QueryLogInterface ¶
type QueryLogInterface interface {
// 日志记录
EnableQueryLog() QueryBuilderInterface
DisableQueryLog() QueryBuilderInterface
// 获取日志
GetQueryLog() []QueryLog
FlushQueryLog() QueryBuilderInterface
// 日志配置
LogQueries(enable bool) QueryBuilderInterface
SetLogger(logger QueryLogger) QueryBuilderInterface
}
QueryLogInterface 查询日志接口
type QueryLogger ¶
type QueryLogger interface {
Log(log QueryLog)
SetLevel(level string)
GetLogs() []QueryLog
Clear()
}
QueryLogger 查询日志记录器接口
type QueryerInterface ¶
type QueryerInterface interface {
Query(query string, args ...interface{}) (*sql.Rows, error)
QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
QueryRow(query string, args ...interface{}) *sql.Row
QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}
QueryerInterface 查询接口
type RelationInterface ¶
type RelationInterface interface {
// 一对一
HasOne(related interface{}, foreignKey ...string) RelationInterface
BelongsTo(related interface{}, foreignKey ...string) RelationInterface
// 一对多
HasMany(related interface{}, foreignKey ...string) RelationInterface
// 多对多
BelongsToMany(related interface{}, pivot ...string) RelationInterface
// 多态关联
MorphTo(name ...string) RelationInterface
MorphOne(related interface{}, name string) RelationInterface
MorphMany(related interface{}, name string) RelationInterface
MorphToMany(related interface{}, name string) RelationInterface
MorphByMany(related interface{}, name string) RelationInterface
// 关联操作
Associate(model interface{}) error
Dissociate() error
Attach(ids interface{}, attributes ...map[string]interface{}) error
Detach(ids ...interface{}) error
Sync(ids interface{}) error
SyncWithoutDetaching(ids interface{}) error
}
RelationInterface 关联接口
type RequiredRule ¶
type RequiredRule struct{}
RequiredRule 必填验证
func (RequiredRule) Validate ¶
func (r RequiredRule) Validate(value interface{}) error
type ResultInterface ¶
type ResultInterface interface {
// 单条记录
First(dest interface{}) error
FirstOrFail(dest interface{}) error
FirstOrDefault(dest interface{}, defaultValue interface{}) error
// 多条记录
Get(dest interface{}) error
All(dest interface{}) error
Chunk(size int, callback func(records interface{}) error) error
// 映射结果
ToMap() (map[string]interface{}, error)
ToMaps() ([]map[string]interface{}, error)
ToStruct(dest interface{}) error
ToStructs(dest interface{}) error
// 聚合函数
Count(column ...string) (int64, error)
Sum(column string) (interface{}, error)
Avg(column string) (interface{}, error)
Max(column string) (interface{}, error)
Min(column string) (interface{}, error)
// 存在性检查
Exists() (bool, error)
DoesntExist() (bool, error)
// 单列值
Pluck(column string, dest interface{}) error
PluckMap(keyColumn, valueColumn string) (map[interface{}]interface{}, error)
Value(column string) (interface{}, error)
}
ResultInterface 结果处理接口
type SqlxAdapter ¶
type SqlxAdapter struct {
// contains filtered or unexported fields
}
SqlxAdapter SQLX数据库适配器 - 实现通用适配器接口
func NewSqlxTxAdapter ¶
func NewSqlxTxAdapter(tx *sqlx.Tx) *SqlxAdapter
NewSqlxTxAdapter 创建SQLX事务适配器
func (*SqlxAdapter) BatchInsert ¶
func (a *SqlxAdapter) BatchInsert(ctx context.Context, table string, data []map[string]interface{}) error
BatchInsert 批量插入
func (*SqlxAdapter) BatchUpdate ¶
func (a *SqlxAdapter) BatchUpdate(ctx context.Context, table string, data []map[string]interface{}, whereColumns []string) error
BatchUpdate 批量更新
func (*SqlxAdapter) Begin ¶
func (a *SqlxAdapter) Begin() (TransactionInterface, error)
func (*SqlxAdapter) BeginTx ¶
func (a *SqlxAdapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
func (*SqlxAdapter) Close ¶
func (a *SqlxAdapter) Close() error
func (*SqlxAdapter) Commit ¶
func (a *SqlxAdapter) Commit() error
func (*SqlxAdapter) Exec ¶
func (a *SqlxAdapter) Exec(query string, args ...interface{}) (sql.Result, error)
func (*SqlxAdapter) ExecContext ¶
func (*SqlxAdapter) Get ¶
func (a *SqlxAdapter) Get(dest interface{}, query string, args ...interface{}) error
func (*SqlxAdapter) GetAdapterName ¶
func (a *SqlxAdapter) GetAdapterName() string
GetAdapterName 获取适配器名称
func (*SqlxAdapter) GetAdapterType ¶
func (a *SqlxAdapter) GetAdapterType() string
GetAdapterType 获取适配器类型
func (*SqlxAdapter) GetContext ¶
func (a *SqlxAdapter) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*SqlxAdapter) GetDB ¶
func (a *SqlxAdapter) GetDB() *sqlx.DB
func (*SqlxAdapter) GetInstance ¶
func (a *SqlxAdapter) GetInstance() interface{}
GetInstance 获取底层SQLX实例
func (*SqlxAdapter) NamedExec ¶
func (a *SqlxAdapter) NamedExec(query string, arg interface{}) (sql.Result, error)
func (*SqlxAdapter) NamedExecContext ¶
func (*SqlxAdapter) NamedQuery ¶
func (a *SqlxAdapter) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
func (*SqlxAdapter) NamedQueryContext ¶
func (*SqlxAdapter) Ping ¶
func (a *SqlxAdapter) Ping() error
func (*SqlxAdapter) PingContext ¶
func (a *SqlxAdapter) PingContext(ctx context.Context) error
func (*SqlxAdapter) Prepare ¶
func (a *SqlxAdapter) Prepare(query string) (StatementInterface, error)
func (*SqlxAdapter) PrepareContext ¶
func (a *SqlxAdapter) PrepareContext(ctx context.Context, query string) (StatementInterface, error)
func (*SqlxAdapter) Query ¶
func (a *SqlxAdapter) Query(query string, args ...interface{}) (*sql.Rows, error)
实现DatabaseInterface接口
func (*SqlxAdapter) QueryContext ¶
func (*SqlxAdapter) QueryRow ¶
func (a *SqlxAdapter) QueryRow(query string, args ...interface{}) *sql.Row
func (*SqlxAdapter) QueryRowContext ¶
func (*SqlxAdapter) QueryRowx ¶
func (a *SqlxAdapter) QueryRowx(query string, args ...interface{}) *sqlx.Row
func (*SqlxAdapter) QueryRowxContext ¶
func (*SqlxAdapter) Queryx ¶
func (a *SqlxAdapter) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
实现SqlxInterface特有方法
func (*SqlxAdapter) QueryxContext ¶
func (*SqlxAdapter) Rollback ¶
func (a *SqlxAdapter) Rollback() error
func (*SqlxAdapter) Select ¶
func (a *SqlxAdapter) Select(dest interface{}, query string, args ...interface{}) error
func (*SqlxAdapter) SelectContext ¶
func (a *SqlxAdapter) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*SqlxAdapter) SupportsBulkInsert ¶
func (a *SqlxAdapter) SupportsBulkInsert() bool
SupportsBulkInsert 批量插入支持检测
func (*SqlxAdapter) SupportsReturning ¶
func (a *SqlxAdapter) SupportsReturning() bool
SupportsReturning RETURNING语句支持检测
func (*SqlxAdapter) SupportsUpsert ¶
func (a *SqlxAdapter) SupportsUpsert() bool
SupportsUpsert Upsert支持检测
type SqlxGetInterface ¶
type SqlxGetInterface interface {
Get(dest interface{}, query string, args ...interface{}) error
GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}
SqlxGetInterface SQLX获取单个结果接口
type SqlxInterface ¶
type SqlxInterface interface {
DatabaseInterface
SqlxQueryInterface
SqlxNamedInterface
SqlxGetInterface
SqlxSelectInterface
}
SqlxInterface SQLX特定接口
type SqlxNamedInterface ¶
type SqlxNamedInterface interface {
NamedExec(query string, arg interface{}) (sql.Result, error)
NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
NamedQueryContext(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)
}
SqlxNamedInterface SQLX命名参数接口
type SqlxQueryInterface ¶
type SqlxQueryInterface interface {
Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
QueryRowx(query string, args ...interface{}) *sqlx.Row
QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
}
SqlxQueryInterface SQLX查询扩展
type SqlxSelectInterface ¶
type SqlxSelectInterface interface {
Select(dest interface{}, query string, args ...interface{}) error
SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}
SqlxSelectInterface SQLX选择多个结果接口
type SqlxStmtAdapter ¶
type SqlxStmtAdapter struct {
// contains filtered or unexported fields
}
SqlxStmtAdapter SQLX语句适配器
func NewSqlxStmtAdapter ¶
func NewSqlxStmtAdapter(stmt *sql.Stmt) *SqlxStmtAdapter
NewSqlxStmtAdapter 创建SQLX语句适配器
func (*SqlxStmtAdapter) Close ¶
func (a *SqlxStmtAdapter) Close() error
func (*SqlxStmtAdapter) Exec ¶
func (a *SqlxStmtAdapter) Exec(args ...interface{}) (sql.Result, error)
func (*SqlxStmtAdapter) ExecContext ¶
func (*SqlxStmtAdapter) Query ¶
func (a *SqlxStmtAdapter) Query(args ...interface{}) (*sql.Rows, error)
func (*SqlxStmtAdapter) QueryContext ¶
func (*SqlxStmtAdapter) QueryRow ¶
func (a *SqlxStmtAdapter) QueryRow(args ...interface{}) *sql.Row
func (*SqlxStmtAdapter) QueryRowContext ¶
func (a *SqlxStmtAdapter) QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
type SqlxTxAdapter ¶
type SqlxTxAdapter struct {
// contains filtered or unexported fields
}
SqlxTxAdapter SQLX事务适配器 (保留原有设计兼容性)
func NewSqlxTxAdapterLegacy ¶
func NewSqlxTxAdapterLegacy(tx *sqlx.Tx) *SqlxTxAdapter
NewSqlxTxAdapterLegacy 创建SQLX事务适配器 (兼容性)
func (*SqlxTxAdapter) Begin ¶
func (a *SqlxTxAdapter) Begin() (TransactionInterface, error)
func (*SqlxTxAdapter) BeginTx ¶
func (a *SqlxTxAdapter) BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
func (*SqlxTxAdapter) Commit ¶
func (a *SqlxTxAdapter) Commit() error
func (*SqlxTxAdapter) Exec ¶
func (a *SqlxTxAdapter) Exec(query string, args ...interface{}) (sql.Result, error)
func (*SqlxTxAdapter) ExecContext ¶
func (*SqlxTxAdapter) Get ¶
func (a *SqlxTxAdapter) Get(dest interface{}, query string, args ...interface{}) error
func (*SqlxTxAdapter) GetContext ¶
func (a *SqlxTxAdapter) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
func (*SqlxTxAdapter) GetTx ¶
func (a *SqlxTxAdapter) GetTx() *sqlx.Tx
func (*SqlxTxAdapter) Query ¶
func (a *SqlxTxAdapter) Query(query string, args ...interface{}) (*sql.Rows, error)
func (*SqlxTxAdapter) QueryContext ¶
func (*SqlxTxAdapter) QueryRow ¶
func (a *SqlxTxAdapter) QueryRow(query string, args ...interface{}) *sql.Row
func (*SqlxTxAdapter) QueryRowContext ¶
func (*SqlxTxAdapter) Rollback ¶
func (a *SqlxTxAdapter) Rollback() error
func (*SqlxTxAdapter) Select ¶
func (a *SqlxTxAdapter) Select(dest interface{}, query string, args ...interface{}) error
func (*SqlxTxAdapter) SelectContext ¶
func (a *SqlxTxAdapter) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
type StatementInterface ¶
type StatementInterface interface {
Exec(args ...interface{}) (sql.Result, error)
ExecContext(ctx context.Context, args ...interface{}) (sql.Result, error)
Query(args ...interface{}) (*sql.Rows, error)
QueryContext(ctx context.Context, args ...interface{}) (*sql.Rows, error)
QueryRow(args ...interface{}) *sql.Row
QueryRowContext(ctx context.Context, args ...interface{}) *sql.Row
Close() error
}
StatementInterface 语句接口
type StringSlice ¶
type StringSlice []string
func (*StringSlice) Scan ¶
func (s *StringSlice) Scan(value interface{}) error
type TransactionInterface ¶
type TransactionInterface interface {
ExecerInterface
Begin() (TransactionInterface, error)
BeginTx(ctx context.Context, opts *sql.TxOptions) (TransactionInterface, error)
Commit() error
Rollback() error
}
TransactionInterface 事务接口
type UniversalAdapterInterface ¶
type UniversalAdapterInterface interface {
DatabaseInterface
// 适配器信息
GetAdapterType() string
GetAdapterName() string
GetDialect() string
// 批量操作
BatchInsert(ctx context.Context, table string, data []map[string]interface{}) error
BatchUpdate(ctx context.Context, table string, data []map[string]interface{}, whereColumns []string) error
// 功能检测
SupportsORM() bool
SupportsUpsert() bool
SupportsBulkInsert() bool
SupportsReturning() bool
// 获取底层实例
GetInstance() interface{}
// 连接统计
GetStats() ConnectionStats
}
UniversalAdapterInterface 通用适配器接口 - 统一所有框架
func AutoDetectAdapter ¶
func AutoDetectAdapter(instance interface{}) (UniversalAdapterInterface, error)
AutoDetectAdapter 自动检测并创建适配器
func NewUniversalAdapter ¶
func NewUniversalAdapter(instance interface{}) (UniversalAdapterInterface, error)
NewUniversalAdapter 创建通用适配器
func WrapGormAsUniversal ¶
func WrapGormAsUniversal(db *gorm.DB) UniversalAdapterInterface
WrapGormAsUniversal 包装gorm.DB为通用适配器
func WrapSqlxAsUniversal ¶
func WrapSqlxAsUniversal(db *sqlx.DB) UniversalAdapterInterface
WrapSqlxAsUniversal 包装sqlx.DB为通用适配器
type UpdateOptions ¶
UpdateOptions 更新选项
type UpdateResult ¶
UpdateResult 更新结果
type V3Features ¶
type V3Features struct {
// contains filtered or unexported fields
}
V3Features v3新功能包装器
func (*V3Features) GetExecutor ¶
func (v3 *V3Features) GetExecutor() executor.Executor
GetExecutor 获取executor
func (*V3Features) SetMiddleware ¶
func (v3 *V3Features) SetMiddleware(middlewares ...middleware.Middleware) *V3Features
SetMiddleware 设置middleware链
type ValidationInterface ¶
type ValidationInterface interface {
// 验证规则
Validate(rules map[string]string) error
ValidateOrFail(rules map[string]string) error
// 自定义验证
ValidateWith(validator func(data interface{}) error) error
// 验证消息
SetValidationMessages(messages map[string]string) QueryBuilderInterface
GetValidationErrors() []string
// 字段验证
Required(fields ...string) QueryBuilderInterface
Unique(field string, ignoreId ...interface{}) QueryBuilderInterface
Exists(field string, table string) QueryBuilderInterface
}
ValidationInterface 验证接口
type ValidationRule ¶
type ValidationRule interface {
Validate(value interface{}) error
}
ValidationRule 验证规则接口
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:02:21 * @FilePath: \go-sqlbuilder\compiler\compiler.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:02:21 * @FilePath: \go-sqlbuilder\compiler\compiler.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:27 * @FilePath: \go-sqlbuilder\constant\adapter.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:27 * @FilePath: \go-sqlbuilder\constant\adapter.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:05:04 * @FilePath: \go-sqlbuilder\executor\executor.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:05:04 * @FilePath: \go-sqlbuilder\executor\executor.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 23:19:22 * @FilePath: \go-sqlbuilder\meta\paging.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 23:19:22 * @FilePath: \go-sqlbuilder\meta\paging.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 21:13:15 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:07:41 * @FilePath: \go-sqlbuilder\persist\query_param.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.
|
* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 21:13:15 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:07:41 * @FilePath: \go-sqlbuilder\persist\query_param.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved. |