Documentation ¶
Index ¶
- func SafeQuery(query string, args ...any) chschema.QueryWithArgs
- type AfterScanRowHook
- type ArrayValues
- type CHModel
- type Config
- type CreateTableQuery
- func (q *CreateTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *CreateTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)
- func (q *CreateTableQuery) Apply(fn func(*CreateTableQuery) *CreateTableQuery) *CreateTableQuery
- func (q *CreateTableQuery) As(table string) *CreateTableQuery
- func (q *CreateTableQuery) ColumnExpr(query string, args ...any) *CreateTableQuery
- func (q *CreateTableQuery) DB() *DB
- func (q *CreateTableQuery) Engine(query string, args ...any) *CreateTableQuery
- func (q *CreateTableQuery) Exec(ctx context.Context) (sql.Result, error)
- func (q *CreateTableQuery) GetModel() Model
- func (q *CreateTableQuery) GetTableName() string
- func (q *CreateTableQuery) IfNotExists() *CreateTableQuery
- func (q *CreateTableQuery) Model(model any) *CreateTableQuery
- func (q *CreateTableQuery) ModelTable(table string) *CreateTableQuery
- func (q *CreateTableQuery) ModelTableExpr(query string, args ...any) *CreateTableQuery
- func (q *CreateTableQuery) OnCluster(cluster string) *CreateTableQuery
- func (q *CreateTableQuery) Operation() string
- func (q *CreateTableQuery) Order(query string, args ...any) *CreateTableQuery
- func (q *CreateTableQuery) Partition(query string, args ...any) *CreateTableQuery
- func (q *CreateTableQuery) Setting(query string, args ...any) *CreateTableQuery
- func (q *CreateTableQuery) TTL(query string, args ...any) *CreateTableQuery
- func (q *CreateTableQuery) Table(tables ...string) *CreateTableQuery
- func (q *CreateTableQuery) TableExpr(query string, args ...any) *CreateTableQuery
- type CreateViewQuery
- func (q *CreateViewQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *CreateViewQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)
- func (q *CreateViewQuery) Apply(fn func(*CreateViewQuery) *CreateViewQuery) *CreateViewQuery
- func (q *CreateViewQuery) Column(columns ...string) *CreateViewQuery
- func (q *CreateViewQuery) ColumnExpr(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) DB() *DB
- func (q *CreateViewQuery) ExcludeColumn(columns ...string) *CreateViewQuery
- func (q *CreateViewQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)
- func (q *CreateViewQuery) GetModel() Model
- func (q *CreateViewQuery) GetTableName() string
- func (q *CreateViewQuery) Group(columns ...string) *CreateViewQuery
- func (q *CreateViewQuery) GroupExpr(group string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) IfNotExists() *CreateViewQuery
- func (q *CreateViewQuery) Materialized() *CreateViewQuery
- func (q *CreateViewQuery) Model(model any) *CreateViewQuery
- func (q *CreateViewQuery) ModelTableExpr(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) OnCluster(cluster string) *CreateViewQuery
- func (q *CreateViewQuery) OnClusterExpr(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) Operation() string
- func (q *CreateViewQuery) OrderExpr(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) Setting(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) Table(tables ...string) *CreateViewQuery
- func (q *CreateViewQuery) TableExpr(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) To(to string) *CreateViewQuery
- func (q *CreateViewQuery) ToExpr(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) View(view string) *CreateViewQuery
- func (q *CreateViewQuery) ViewExpr(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) Where(query string, args ...any) *CreateViewQuery
- func (q *CreateViewQuery) WhereGroup(sep string, fn func(*CreateViewQuery) *CreateViewQuery) *CreateViewQuery
- func (q *CreateViewQuery) WhereOr(query string, args ...any) *CreateViewQuery
- type DB
- func (db *DB) AddQueryHook(hook QueryHook)
- func (db *DB) Close() error
- func (db *DB) Config() *Config
- func (db *DB) Exec(query string, args ...any) (sql.Result, error)
- func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
- func (db *DB) FormatQuery(query string, args ...any) string
- func (db *DB) Formatter() chschema.Formatter
- func (db *DB) NewCreateTable() *CreateTableQuery
- func (db *DB) NewCreateView() *CreateViewQuery
- func (db *DB) NewDropTable() *DropTableQuery
- func (db *DB) NewDropView() *DropViewQuery
- func (db *DB) NewInsert() *InsertQuery
- func (db *DB) NewRaw(query string, args ...any) *RawQuery
- func (db *DB) NewSelect() *SelectQuery
- func (db *DB) NewTruncateTable() *TruncateTableQuery
- func (db *DB) Ping(ctx context.Context) error
- func (db *DB) Query(query string, args ...any) (*Rows, error)
- func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*Rows, error)
- func (db *DB) QueryRow(query string, args ...any) *Row
- func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *Row
- func (db *DB) ResetModel(ctx context.Context, models ...any) error
- func (db *DB) Stats() DBStats
- func (db *DB) String() string
- func (db *DB) WithFormatter(fmter chschema.Formatter) *DB
- func (db *DB) WithTimeout(d time.Duration) *DB
- type DBStats
- type DropTableQuery
- func (q *DropTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *DropTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)
- func (q *DropTableQuery) DB() *DB
- func (q *DropTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)
- func (q *DropTableQuery) GetModel() Model
- func (q *DropTableQuery) GetTableName() string
- func (q *DropTableQuery) IfExists() *DropTableQuery
- func (q *DropTableQuery) Model(model any) *DropTableQuery
- func (q *DropTableQuery) ModelTableExpr(query string, args ...any) *DropTableQuery
- func (q *DropTableQuery) OnCluster(cluster string) *DropTableQuery
- func (q *DropTableQuery) Operation() string
- func (q *DropTableQuery) Table(tables ...string) *DropTableQuery
- func (q *DropTableQuery) TableExpr(query string, args ...any) *DropTableQuery
- type DropViewQuery
- func (q *DropViewQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *DropViewQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)
- func (q *DropViewQuery) Apply(fn func(*DropViewQuery) *DropViewQuery) *DropViewQuery
- func (q *DropViewQuery) DB() *DB
- func (q *DropViewQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)
- func (q *DropViewQuery) GetModel() Model
- func (q *DropViewQuery) GetTableName() string
- func (q *DropViewQuery) IfExists() *DropViewQuery
- func (q *DropViewQuery) Model(model any) *DropViewQuery
- func (q *DropViewQuery) OnCluster(cluster string) *DropViewQuery
- func (q *DropViewQuery) OnClusterExpr(query string, args ...any) *DropViewQuery
- func (q *DropViewQuery) Operation() string
- func (q *DropViewQuery) View(view string) *DropViewQuery
- func (q *DropViewQuery) ViewExpr(query string, args ...any) *DropViewQuery
- type Error
- type Ident
- type InValues
- type InsertQuery
- func (q *InsertQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *InsertQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)
- func (q *InsertQuery) Column(columns ...string) *InsertQuery
- func (q *InsertQuery) ColumnExpr(query string, args ...any) *InsertQuery
- func (q *InsertQuery) DB() *DB
- func (q *InsertQuery) ExcludeColumn(columns ...string) *InsertQuery
- func (q *InsertQuery) Exec(ctx context.Context) (sql.Result, error)
- func (q *InsertQuery) GetModel() Model
- func (q *InsertQuery) GetTableName() string
- func (q *InsertQuery) Model(model any) *InsertQuery
- func (q *InsertQuery) ModelTable(table string) *InsertQuery
- func (q *InsertQuery) ModelTableExpr(query string, args ...any) *InsertQuery
- func (q *InsertQuery) Operation() string
- func (q *InsertQuery) Setting(query string, args ...any) *InsertQuery
- func (q *InsertQuery) Table(tables ...string) *InsertQuery
- func (q *InsertQuery) TableExpr(query string, args ...any) *InsertQuery
- func (q *InsertQuery) Where(query string, args ...any) *InsertQuery
- func (q *InsertQuery) WhereOr(query string, args ...any) *InsertQuery
- type ListValues
- type Model
- type Name
- type Option
- func WithAddr(addr string) Option
- func WithAutoCreateDatabase(enabled bool) Option
- func WithCluster(cluster string) Option
- func WithCompression(enabled bool) Option
- func WithConnMaxIdleTime(d time.Duration) Option
- func WithConnMaxLifetime(d time.Duration) Option
- func WithDSN(dsn string) Option
- func WithDatabase(database string) Option
- func WithDialTimeout(timeout time.Duration) Option
- func WithDiscardUnknownColumns() Option
- func WithInsecure(on bool) Option
- func WithMaxRetries(maxRetries int) Option
- func WithMaxRetryBackoff(backoff time.Duration) Option
- func WithMinRetryBackoff(backoff time.Duration) Option
- func WithPassword(password string) Option
- func WithPoolSize(poolSize int) Option
- func WithPoolTimeout(timeout time.Duration) Option
- func WithQuerySettings(params map[string]any) Option
- func WithReadTimeout(timeout time.Duration) Option
- func WithTLSConfig(conf *tls.Config) Option
- func WithTimeout(timeout time.Duration) Option
- func WithUser(user string) Option
- func WithWriteTimeout(timeout time.Duration) Option
- type Query
- type QueryEvent
- type QueryHook
- type RawQuery
- func (q *RawQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *RawQuery) AppendQuery(fmter chschema.Formatter, b []byte) ([]byte, error)
- func (q *RawQuery) DB() *DB
- func (q *RawQuery) GetModel() Model
- func (q *RawQuery) GetTableName() string
- func (q *RawQuery) Operation() string
- func (q *RawQuery) Scan(ctx context.Context, dest ...any) error
- func (q *RawQuery) ScanColumns(ctx context.Context, dest ...any) error
- type Row
- type Rows
- type Safe
- type SelectQuery
- func (q *SelectQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *SelectQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)
- func (q *SelectQuery) Apply(fn func(*SelectQuery) *SelectQuery) *SelectQuery
- func (q *SelectQuery) Clone() *SelectQuery
- func (q *SelectQuery) Column(columns ...string) *SelectQuery
- func (q *SelectQuery) ColumnExpr(query string, args ...any) *SelectQuery
- func (q *SelectQuery) Count(ctx context.Context) (int, error)
- func (q *SelectQuery) DB() *DB
- func (q *SelectQuery) Distinct() *SelectQuery
- func (q *SelectQuery) DistinctOn(query string, args ...any) *SelectQuery
- func (q *SelectQuery) Err(err error) *SelectQuery
- func (q *SelectQuery) ExcludeColumn(columns ...string) *SelectQuery
- func (q *SelectQuery) Final() *SelectQuery
- func (q *SelectQuery) GetModel() Model
- func (q *SelectQuery) GetTableName() string
- func (q *SelectQuery) Group(columns ...string) *SelectQuery
- func (q *SelectQuery) GroupExpr(group string, args ...any) *SelectQuery
- func (q *SelectQuery) Having(having string, args ...any) *SelectQuery
- func (q *SelectQuery) Join(join string, args ...any) *SelectQuery
- func (q *SelectQuery) JoinOn(cond string, args ...any) *SelectQuery
- func (q *SelectQuery) JoinOnOr(cond string, args ...any) *SelectQuery
- func (q *SelectQuery) Limit(limit int) *SelectQuery
- func (q *SelectQuery) Model(model any) *SelectQuery
- func (q *SelectQuery) ModelTable(table string) *SelectQuery
- func (q *SelectQuery) ModelTableExpr(query string, args ...any) *SelectQuery
- func (q *SelectQuery) Offset(offset int) *SelectQuery
- func (q *SelectQuery) Operation() string
- func (q *SelectQuery) Order(orders ...string) *SelectQuery
- func (q *SelectQuery) OrderExpr(order string, args ...any) *SelectQuery
- func (q *SelectQuery) Prewhere(query string, args ...any) *SelectQuery
- func (q *SelectQuery) PrewhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery
- func (q *SelectQuery) PrewhereOr(query string, args ...any) *SelectQuery
- func (q *SelectQuery) Sample(query string, args ...any) *SelectQuery
- func (q *SelectQuery) Scan(ctx context.Context, values ...any) error
- func (q *SelectQuery) ScanAndCount(ctx context.Context, values ...any) (count int, firstErr error)
- func (q *SelectQuery) ScanColumns(ctx context.Context, values ...any) error
- func (q *SelectQuery) Setting(query string, args ...any) *SelectQuery
- func (q *SelectQuery) String() string
- func (q *SelectQuery) Table(tables ...string) *SelectQuery
- func (q *SelectQuery) TableExpr(query string, args ...any) *SelectQuery
- func (q *SelectQuery) Union(other *SelectQuery) *SelectQuery
- func (q *SelectQuery) UnionAll(other *SelectQuery) *SelectQuery
- func (q *SelectQuery) Where(query string, args ...any) *SelectQuery
- func (q *SelectQuery) WhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery
- func (q *SelectQuery) WhereOr(query string, args ...any) *SelectQuery
- func (q *SelectQuery) With(name string, subq chschema.QueryAppender) *SelectQuery
- func (q *SelectQuery) WithAlias(name, query string, args ...any) *SelectQuery
- type TableModel
- type TruncateTableQuery
- func (q *TruncateTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)
- func (q *TruncateTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)
- func (q *TruncateTableQuery) DB() *DB
- func (q *TruncateTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)
- func (q *TruncateTableQuery) GetModel() Model
- func (q *TruncateTableQuery) GetTableName() string
- func (q *TruncateTableQuery) IfExists() *TruncateTableQuery
- func (q *TruncateTableQuery) Model(model any) *TruncateTableQuery
- func (q *TruncateTableQuery) Operation() string
- func (q *TruncateTableQuery) Table(tables ...string) *TruncateTableQuery
- func (q *TruncateTableQuery) TableExpr(query string, args ...any) *TruncateTableQuery
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AfterScanRowHook ¶
type AfterScanRowHook = chschema.AfterScanRowHook
type ArrayValues ¶
type ArrayValues struct {
// contains filtered or unexported fields
}
func Array ¶
func Array(slice any) ArrayValues
func (ArrayValues) AppendQuery ¶
type Config ¶
type Config struct { chpool.Config Compression bool Addr string User string Password string Database string Cluster string DialTimeout time.Duration TLSConfig *tls.Config QuerySettings map[string]any ReadTimeout time.Duration WriteTimeout time.Duration MaxRetries int MinRetryBackoff time.Duration MaxRetryBackoff time.Duration }
type CreateTableQuery ¶
type CreateTableQuery struct {
// contains filtered or unexported fields
}
func NewCreateTableQuery ¶
func NewCreateTableQuery(db *DB) *CreateTableQuery
func (*CreateTableQuery) AppendNamedArg ¶
func (*CreateTableQuery) AppendQuery ¶
func (*CreateTableQuery) Apply ¶
func (q *CreateTableQuery) Apply(fn func(*CreateTableQuery) *CreateTableQuery) *CreateTableQuery
func (*CreateTableQuery) As ¶
func (q *CreateTableQuery) As(table string) *CreateTableQuery
func (*CreateTableQuery) ColumnExpr ¶
func (q *CreateTableQuery) ColumnExpr(query string, args ...any) *CreateTableQuery
func (*CreateTableQuery) Engine ¶
func (q *CreateTableQuery) Engine(query string, args ...any) *CreateTableQuery
func (*CreateTableQuery) GetTableName ¶
func (q *CreateTableQuery) GetTableName() string
func (*CreateTableQuery) IfNotExists ¶
func (q *CreateTableQuery) IfNotExists() *CreateTableQuery
func (*CreateTableQuery) Model ¶
func (q *CreateTableQuery) Model(model any) *CreateTableQuery
func (*CreateTableQuery) ModelTable ¶
func (q *CreateTableQuery) ModelTable(table string) *CreateTableQuery
func (*CreateTableQuery) ModelTableExpr ¶
func (q *CreateTableQuery) ModelTableExpr(query string, args ...any) *CreateTableQuery
func (*CreateTableQuery) OnCluster ¶
func (q *CreateTableQuery) OnCluster(cluster string) *CreateTableQuery
func (*CreateTableQuery) Operation ¶
func (q *CreateTableQuery) Operation() string
func (*CreateTableQuery) Order ¶
func (q *CreateTableQuery) Order(query string, args ...any) *CreateTableQuery
func (*CreateTableQuery) Partition ¶
func (q *CreateTableQuery) Partition(query string, args ...any) *CreateTableQuery
func (*CreateTableQuery) Setting ¶
func (q *CreateTableQuery) Setting(query string, args ...any) *CreateTableQuery
func (*CreateTableQuery) TTL ¶
func (q *CreateTableQuery) TTL(query string, args ...any) *CreateTableQuery
func (*CreateTableQuery) Table ¶
func (q *CreateTableQuery) Table(tables ...string) *CreateTableQuery
func (*CreateTableQuery) TableExpr ¶
func (q *CreateTableQuery) TableExpr(query string, args ...any) *CreateTableQuery
type CreateViewQuery ¶
type CreateViewQuery struct {
// contains filtered or unexported fields
}
func NewCreateViewQuery ¶
func NewCreateViewQuery(db *DB) *CreateViewQuery
func (*CreateViewQuery) AppendNamedArg ¶
func (*CreateViewQuery) AppendQuery ¶
func (*CreateViewQuery) Apply ¶
func (q *CreateViewQuery) Apply(fn func(*CreateViewQuery) *CreateViewQuery) *CreateViewQuery
func (*CreateViewQuery) Column ¶
func (q *CreateViewQuery) Column(columns ...string) *CreateViewQuery
func (*CreateViewQuery) ColumnExpr ¶
func (q *CreateViewQuery) ColumnExpr(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) ExcludeColumn ¶
func (q *CreateViewQuery) ExcludeColumn(columns ...string) *CreateViewQuery
func (*CreateViewQuery) GetTableName ¶
func (q *CreateViewQuery) GetTableName() string
func (*CreateViewQuery) Group ¶
func (q *CreateViewQuery) Group(columns ...string) *CreateViewQuery
func (*CreateViewQuery) GroupExpr ¶
func (q *CreateViewQuery) GroupExpr(group string, args ...any) *CreateViewQuery
func (*CreateViewQuery) IfNotExists ¶
func (q *CreateViewQuery) IfNotExists() *CreateViewQuery
func (*CreateViewQuery) Materialized ¶
func (q *CreateViewQuery) Materialized() *CreateViewQuery
func (*CreateViewQuery) Model ¶
func (q *CreateViewQuery) Model(model any) *CreateViewQuery
func (*CreateViewQuery) ModelTableExpr ¶
func (q *CreateViewQuery) ModelTableExpr(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) OnCluster ¶
func (q *CreateViewQuery) OnCluster(cluster string) *CreateViewQuery
func (*CreateViewQuery) OnClusterExpr ¶
func (q *CreateViewQuery) OnClusterExpr(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) Operation ¶
func (q *CreateViewQuery) Operation() string
func (*CreateViewQuery) OrderExpr ¶
func (q *CreateViewQuery) OrderExpr(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) Setting ¶
func (q *CreateViewQuery) Setting(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) Table ¶
func (q *CreateViewQuery) Table(tables ...string) *CreateViewQuery
func (*CreateViewQuery) TableExpr ¶
func (q *CreateViewQuery) TableExpr(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) To ¶
func (q *CreateViewQuery) To(to string) *CreateViewQuery
func (*CreateViewQuery) ToExpr ¶
func (q *CreateViewQuery) ToExpr(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) View ¶
func (q *CreateViewQuery) View(view string) *CreateViewQuery
func (*CreateViewQuery) ViewExpr ¶
func (q *CreateViewQuery) ViewExpr(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) Where ¶
func (q *CreateViewQuery) Where(query string, args ...any) *CreateViewQuery
func (*CreateViewQuery) WhereGroup ¶
func (q *CreateViewQuery) WhereGroup(sep string, fn func(*CreateViewQuery) *CreateViewQuery) *CreateViewQuery
func (*CreateViewQuery) WhereOr ¶
func (q *CreateViewQuery) WhereOr(query string, args ...any) *CreateViewQuery
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) AddQueryHook ¶
AddQueryHook adds a hook into query processing.
func (*DB) Close ¶
Close closes the database client, releasing any open resources.
It is rare to Close a DB, as the DB handle is meant to be long-lived and shared between many goroutines.
func (*DB) ExecContext ¶
func (*DB) NewCreateTable ¶
func (db *DB) NewCreateTable() *CreateTableQuery
func (*DB) NewCreateView ¶
func (db *DB) NewCreateView() *CreateViewQuery
func (*DB) NewDropTable ¶
func (db *DB) NewDropTable() *DropTableQuery
func (*DB) NewDropView ¶
func (db *DB) NewDropView() *DropViewQuery
func (*DB) NewInsert ¶
func (db *DB) NewInsert() *InsertQuery
func (*DB) NewSelect ¶
func (db *DB) NewSelect() *SelectQuery
func (*DB) NewTruncateTable ¶
func (db *DB) NewTruncateTable() *TruncateTableQuery
func (*DB) QueryContext ¶
func (*DB) QueryRowContext ¶
type DropTableQuery ¶
type DropTableQuery struct {
// contains filtered or unexported fields
}
func NewDropTableQuery ¶
func NewDropTableQuery(db *DB) *DropTableQuery
func (*DropTableQuery) AppendNamedArg ¶
func (*DropTableQuery) AppendQuery ¶
func (*DropTableQuery) GetTableName ¶
func (q *DropTableQuery) GetTableName() string
func (*DropTableQuery) IfExists ¶
func (q *DropTableQuery) IfExists() *DropTableQuery
func (*DropTableQuery) Model ¶
func (q *DropTableQuery) Model(model any) *DropTableQuery
func (*DropTableQuery) ModelTableExpr ¶
func (q *DropTableQuery) ModelTableExpr(query string, args ...any) *DropTableQuery
func (*DropTableQuery) OnCluster ¶
func (q *DropTableQuery) OnCluster(cluster string) *DropTableQuery
func (*DropTableQuery) Operation ¶
func (q *DropTableQuery) Operation() string
func (*DropTableQuery) Table ¶
func (q *DropTableQuery) Table(tables ...string) *DropTableQuery
func (*DropTableQuery) TableExpr ¶
func (q *DropTableQuery) TableExpr(query string, args ...any) *DropTableQuery
type DropViewQuery ¶
type DropViewQuery struct {
// contains filtered or unexported fields
}
func NewDropViewQuery ¶
func NewDropViewQuery(db *DB) *DropViewQuery
func (*DropViewQuery) AppendNamedArg ¶
func (*DropViewQuery) AppendQuery ¶
func (*DropViewQuery) Apply ¶
func (q *DropViewQuery) Apply(fn func(*DropViewQuery) *DropViewQuery) *DropViewQuery
func (*DropViewQuery) GetTableName ¶
func (q *DropViewQuery) GetTableName() string
func (*DropViewQuery) IfExists ¶
func (q *DropViewQuery) IfExists() *DropViewQuery
func (*DropViewQuery) Model ¶
func (q *DropViewQuery) Model(model any) *DropViewQuery
func (*DropViewQuery) OnCluster ¶
func (q *DropViewQuery) OnCluster(cluster string) *DropViewQuery
func (*DropViewQuery) OnClusterExpr ¶
func (q *DropViewQuery) OnClusterExpr(query string, args ...any) *DropViewQuery
func (*DropViewQuery) Operation ¶
func (q *DropViewQuery) Operation() string
func (*DropViewQuery) View ¶
func (q *DropViewQuery) View(view string) *DropViewQuery
func (*DropViewQuery) ViewExpr ¶
func (q *DropViewQuery) ViewExpr(query string, args ...any) *DropViewQuery
type Error ¶
type InsertQuery ¶
type InsertQuery struct {
// contains filtered or unexported fields
}
func NewInsertQuery ¶
func NewInsertQuery(db *DB) *InsertQuery
func (*InsertQuery) AppendNamedArg ¶
func (*InsertQuery) AppendQuery ¶
func (*InsertQuery) Column ¶
func (q *InsertQuery) Column(columns ...string) *InsertQuery
func (*InsertQuery) ColumnExpr ¶
func (q *InsertQuery) ColumnExpr(query string, args ...any) *InsertQuery
func (*InsertQuery) ExcludeColumn ¶
func (q *InsertQuery) ExcludeColumn(columns ...string) *InsertQuery
func (*InsertQuery) GetTableName ¶
func (q *InsertQuery) GetTableName() string
func (*InsertQuery) Model ¶
func (q *InsertQuery) Model(model any) *InsertQuery
func (*InsertQuery) ModelTable ¶
func (q *InsertQuery) ModelTable(table string) *InsertQuery
func (*InsertQuery) ModelTableExpr ¶
func (q *InsertQuery) ModelTableExpr(query string, args ...any) *InsertQuery
func (*InsertQuery) Operation ¶
func (q *InsertQuery) Operation() string
func (*InsertQuery) Setting ¶
func (q *InsertQuery) Setting(query string, args ...any) *InsertQuery
func (*InsertQuery) Table ¶
func (q *InsertQuery) Table(tables ...string) *InsertQuery
func (*InsertQuery) TableExpr ¶
func (q *InsertQuery) TableExpr(query string, args ...any) *InsertQuery
func (*InsertQuery) Where ¶
func (q *InsertQuery) Where(query string, args ...any) *InsertQuery
func (*InsertQuery) WhereOr ¶
func (q *InsertQuery) WhereOr(query string, args ...any) *InsertQuery
type ListValues ¶
type ListValues struct {
// contains filtered or unexported fields
}
func List ¶
func List(slice any) ListValues
func (ListValues) AppendQuery ¶
type Option ¶
type Option func(db *DB)
func WithAutoCreateDatabase ¶
func WithCluster ¶
func WithCompression ¶
WithCompression enables/disables LZ4 compression.
func WithConnMaxIdleTime ¶
SetConnMaxIdleTime sets the maximum amount of time a connection may be idle. Expired connections may be closed lazily before reuse.
If d <= 0, connections are not closed due to a connection's idle time.
ClickHouse closes idle connections after 1 hour (see idle_connection_timeout).
func WithConnMaxLifetime ¶
If d <= 0, connections are not closed due to a connection's age.
func WithDatabase ¶
func WithDialTimeout ¶
WithDialTimeout configures dial timeout for establishing new connections. Default is 5 seconds.
func WithDiscardUnknownColumns ¶
func WithDiscardUnknownColumns() Option
func WithInsecure ¶
func WithMaxRetries ¶
WithMaxRetries configures maximum number of retries before giving up. Default is to retry query 2 times.
func WithMaxRetryBackoff ¶
WithMaxRetryBackoff configures maximum backoff between each retry. Default is 4 seconds; -1 disables backoff.
func WithMinRetryBackoff ¶
WithMinRetryBackoff configures minimum backoff between each retry. Default is 250 milliseconds; -1 disables backoff.
func WithPassword ¶
func WithPoolSize ¶
WithPoolSize configures maximum number of socket connections. Default is 2 connections per every CPU as reported by runtime.NumCPU.
func WithPoolTimeout ¶
WithPoolTimeout configures time for which client waits for free connection if all connections are busy before returning an error. Default is 30 seconds if ReadTimeOut is not defined, otherwise, ReadTimeout + 1 second.
func WithQuerySettings ¶
func WithReadTimeout ¶
WithReadTimeout configures timeout for socket reads. If reached, commands will fail with a timeout instead of blocking.
func WithTLSConfig ¶
WithTLSConfig configures TLS config for secure connections.
func WithTimeout ¶
func WithWriteTimeout ¶
WithWriteTimeout configures timeout for socket writes. If reached, commands will fail with a timeout instead of blocking.
type QueryEvent ¶
type QueryEvent struct { DB *DB Model Model IQuery Query Query string QueryArgs []any StartTime time.Time Result sql.Result Err error Stash map[any]any }
func (*QueryEvent) Operation ¶
func (e *QueryEvent) Operation() string
type QueryHook ¶
type QueryHook interface { BeforeQuery(context.Context, *QueryEvent) context.Context AfterQuery(context.Context, *QueryEvent) }
QueryHook ...
type RawQuery ¶
type RawQuery struct {
// contains filtered or unexported fields
}
func (*RawQuery) AppendNamedArg ¶
func (*RawQuery) AppendQuery ¶
func (*RawQuery) GetTableName ¶
func (q *RawQuery) GetTableName() string
type Rows ¶
type Rows struct {
// contains filtered or unexported fields
}
Rows is the result of a query. Its cursor starts before the first row of the result set. Use Next to advance from row to row.
func (*Rows) ColumnTypes ¶
func (rs *Rows) ColumnTypes() ([]*sql.ColumnType, error)
func (*Rows) NextResultSet ¶
type SelectQuery ¶
type SelectQuery struct {
// contains filtered or unexported fields
}
func NewSelectQuery ¶
func NewSelectQuery(db *DB) *SelectQuery
func (*SelectQuery) AppendNamedArg ¶
func (*SelectQuery) AppendQuery ¶
func (*SelectQuery) Apply ¶
func (q *SelectQuery) Apply(fn func(*SelectQuery) *SelectQuery) *SelectQuery
func (*SelectQuery) Clone ¶
func (q *SelectQuery) Clone() *SelectQuery
func (*SelectQuery) Column ¶
func (q *SelectQuery) Column(columns ...string) *SelectQuery
func (*SelectQuery) ColumnExpr ¶
func (q *SelectQuery) ColumnExpr(query string, args ...any) *SelectQuery
func (*SelectQuery) Count ¶
func (q *SelectQuery) Count(ctx context.Context) (int, error)
Count returns number of rows matching the query using count aggregate function.
func (*SelectQuery) Distinct ¶
func (q *SelectQuery) Distinct() *SelectQuery
func (*SelectQuery) DistinctOn ¶
func (q *SelectQuery) DistinctOn(query string, args ...any) *SelectQuery
func (*SelectQuery) Err ¶
func (q *SelectQuery) Err(err error) *SelectQuery
func (*SelectQuery) ExcludeColumn ¶
func (q *SelectQuery) ExcludeColumn(columns ...string) *SelectQuery
func (*SelectQuery) Final ¶
func (q *SelectQuery) Final() *SelectQuery
func (*SelectQuery) GetTableName ¶
func (q *SelectQuery) GetTableName() string
func (*SelectQuery) Group ¶
func (q *SelectQuery) Group(columns ...string) *SelectQuery
func (*SelectQuery) GroupExpr ¶
func (q *SelectQuery) GroupExpr(group string, args ...any) *SelectQuery
func (*SelectQuery) Having ¶
func (q *SelectQuery) Having(having string, args ...any) *SelectQuery
func (*SelectQuery) Join ¶
func (q *SelectQuery) Join(join string, args ...any) *SelectQuery
func (*SelectQuery) JoinOn ¶
func (q *SelectQuery) JoinOn(cond string, args ...any) *SelectQuery
func (*SelectQuery) JoinOnOr ¶
func (q *SelectQuery) JoinOnOr(cond string, args ...any) *SelectQuery
func (*SelectQuery) Limit ¶
func (q *SelectQuery) Limit(limit int) *SelectQuery
func (*SelectQuery) Model ¶
func (q *SelectQuery) Model(model any) *SelectQuery
func (*SelectQuery) ModelTable ¶
func (q *SelectQuery) ModelTable(table string) *SelectQuery
func (*SelectQuery) ModelTableExpr ¶
func (q *SelectQuery) ModelTableExpr(query string, args ...any) *SelectQuery
func (*SelectQuery) Offset ¶
func (q *SelectQuery) Offset(offset int) *SelectQuery
func (*SelectQuery) Operation ¶
func (q *SelectQuery) Operation() string
func (*SelectQuery) Order ¶
func (q *SelectQuery) Order(orders ...string) *SelectQuery
func (*SelectQuery) OrderExpr ¶
func (q *SelectQuery) OrderExpr(order string, args ...any) *SelectQuery
Order adds sort order to the Query.
func (*SelectQuery) Prewhere ¶
func (q *SelectQuery) Prewhere(query string, args ...any) *SelectQuery
func (*SelectQuery) PrewhereGroup ¶
func (q *SelectQuery) PrewhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery
func (*SelectQuery) PrewhereOr ¶
func (q *SelectQuery) PrewhereOr(query string, args ...any) *SelectQuery
func (*SelectQuery) Sample ¶
func (q *SelectQuery) Sample(query string, args ...any) *SelectQuery
func (*SelectQuery) ScanAndCount ¶
func (q *SelectQuery) ScanAndCount( ctx context.Context, values ...any, ) (count int, firstErr error)
SelectAndCount runs Select and Count in two goroutines, waits for them to finish and returns the result. If query limit is -1 it does not select any data and only counts the results.
func (*SelectQuery) ScanColumns ¶
func (q *SelectQuery) ScanColumns(ctx context.Context, values ...any) error
func (*SelectQuery) Setting ¶
func (q *SelectQuery) Setting(query string, args ...any) *SelectQuery
func (*SelectQuery) String ¶
func (q *SelectQuery) String() string
func (*SelectQuery) Table ¶
func (q *SelectQuery) Table(tables ...string) *SelectQuery
func (*SelectQuery) TableExpr ¶
func (q *SelectQuery) TableExpr(query string, args ...any) *SelectQuery
func (*SelectQuery) Union ¶
func (q *SelectQuery) Union(other *SelectQuery) *SelectQuery
func (*SelectQuery) UnionAll ¶
func (q *SelectQuery) UnionAll(other *SelectQuery) *SelectQuery
func (*SelectQuery) Where ¶
func (q *SelectQuery) Where(query string, args ...any) *SelectQuery
func (*SelectQuery) WhereGroup ¶
func (q *SelectQuery) WhereGroup(sep string, fn func(*SelectQuery) *SelectQuery) *SelectQuery
func (*SelectQuery) WhereOr ¶
func (q *SelectQuery) WhereOr(query string, args ...any) *SelectQuery
func (*SelectQuery) With ¶
func (q *SelectQuery) With(name string, subq chschema.QueryAppender) *SelectQuery
func (*SelectQuery) WithAlias ¶
func (q *SelectQuery) WithAlias(name, query string, args ...any) *SelectQuery
type TableModel ¶
type TruncateTableQuery ¶
type TruncateTableQuery struct {
// contains filtered or unexported fields
}
func NewTruncateTableQuery ¶
func NewTruncateTableQuery(db *DB) *TruncateTableQuery
func (*TruncateTableQuery) AppendNamedArg ¶
func (*TruncateTableQuery) AppendQuery ¶
func (*TruncateTableQuery) GetTableName ¶
func (q *TruncateTableQuery) GetTableName() string
func (*TruncateTableQuery) IfExists ¶
func (q *TruncateTableQuery) IfExists() *TruncateTableQuery
func (*TruncateTableQuery) Model ¶
func (q *TruncateTableQuery) Model(model any) *TruncateTableQuery
func (*TruncateTableQuery) Operation ¶
func (q *TruncateTableQuery) Operation() string
func (*TruncateTableQuery) Table ¶
func (q *TruncateTableQuery) Table(tables ...string) *TruncateTableQuery
func (*TruncateTableQuery) TableExpr ¶
func (q *TruncateTableQuery) TableExpr(query string, args ...any) *TruncateTableQuery
Source Files ¶
- ch.go
- config.go
- db.go
- hook.go
- model.go
- model_map.go
- model_scan.go
- model_slice_map.go
- model_table_slice.go
- model_table_struct.go
- proto.go
- query_base.go
- query_insert.go
- query_raw.go
- query_select.go
- query_table_create.go
- query_table_drop.go
- query_table_truncate.go
- query_view_create.go
- query_view_drop.go
- reflect.go