ch

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SafeQuery

func SafeQuery(query string, args ...any) chschema.QueryWithArgs

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

func (in ArrayValues) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

type CHModel

type CHModel = chschema.CHModel

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 (q *CreateTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*CreateTableQuery) AppendQuery

func (q *CreateTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

func (*CreateTableQuery) Apply

func (*CreateTableQuery) As

func (*CreateTableQuery) ColumnExpr

func (q *CreateTableQuery) ColumnExpr(query string, args ...any) *CreateTableQuery

func (*CreateTableQuery) DB

func (q *CreateTableQuery) DB() *DB

func (*CreateTableQuery) Engine

func (q *CreateTableQuery) Engine(query string, args ...any) *CreateTableQuery

func (*CreateTableQuery) Exec

func (q *CreateTableQuery) Exec(ctx context.Context) (sql.Result, error)

func (*CreateTableQuery) GetModel

func (q *CreateTableQuery) GetModel() Model

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 (q *CreateViewQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*CreateViewQuery) AppendQuery

func (q *CreateViewQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

func (*CreateViewQuery) Apply

func (*CreateViewQuery) Column

func (q *CreateViewQuery) Column(columns ...string) *CreateViewQuery

func (*CreateViewQuery) ColumnExpr

func (q *CreateViewQuery) ColumnExpr(query string, args ...any) *CreateViewQuery

func (*CreateViewQuery) DB

func (q *CreateViewQuery) DB() *DB

func (*CreateViewQuery) ExcludeColumn

func (q *CreateViewQuery) ExcludeColumn(columns ...string) *CreateViewQuery

func (*CreateViewQuery) Exec

func (q *CreateViewQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*CreateViewQuery) GetModel

func (q *CreateViewQuery) GetModel() Model

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 (*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 Connect

func Connect(opts ...Option) *DB

func (*DB) AddQueryHook

func (db *DB) AddQueryHook(hook QueryHook)

AddQueryHook adds a hook into query processing.

func (*DB) Close

func (db *DB) Close() error

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) Config

func (db *DB) Config() *Config

func (*DB) Exec

func (db *DB) Exec(query string, args ...any) (sql.Result, error)

func (*DB) ExecContext

func (db *DB) ExecContext(
	ctx context.Context, query string, args ...any,
) (sql.Result, error)

func (*DB) FormatQuery

func (db *DB) FormatQuery(query string, args ...any) string

func (*DB) Formatter

func (db *DB) Formatter() chschema.Formatter

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) NewRaw

func (db *DB) NewRaw(query string, args ...any) *RawQuery

func (*DB) NewSelect

func (db *DB) NewSelect() *SelectQuery

func (*DB) NewTruncateTable

func (db *DB) NewTruncateTable() *TruncateTableQuery

func (*DB) Ping

func (db *DB) Ping(ctx context.Context) error

func (*DB) Query

func (db *DB) Query(query string, args ...any) (*Rows, error)

func (*DB) QueryContext

func (db *DB) QueryContext(
	ctx context.Context, query string, args ...any,
) (*Rows, error)

func (*DB) QueryRow

func (db *DB) QueryRow(query string, args ...any) *Row

func (*DB) QueryRowContext

func (db *DB) QueryRowContext(ctx context.Context, query string, args ...any) *Row

func (*DB) ResetModel

func (db *DB) ResetModel(ctx context.Context, models ...any) error

func (*DB) Stats

func (db *DB) Stats() DBStats

func (*DB) String

func (db *DB) String() string

func (*DB) WithFormatter

func (db *DB) WithFormatter(fmter chschema.Formatter) *DB

func (*DB) WithTimeout

func (db *DB) WithTimeout(d time.Duration) *DB

type DBStats

type DBStats struct {
	Queries uint64
	Errors  uint64
}

type DropTableQuery

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

func NewDropTableQuery

func NewDropTableQuery(db *DB) *DropTableQuery

func (*DropTableQuery) AppendNamedArg

func (q *DropTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*DropTableQuery) AppendQuery

func (q *DropTableQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

func (*DropTableQuery) DB

func (q *DropTableQuery) DB() *DB

func (*DropTableQuery) Exec

func (q *DropTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*DropTableQuery) GetModel

func (q *DropTableQuery) GetModel() Model

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 (q *DropViewQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*DropViewQuery) AppendQuery

func (q *DropViewQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

func (*DropViewQuery) Apply

func (*DropViewQuery) DB

func (q *DropViewQuery) DB() *DB

func (*DropViewQuery) Exec

func (q *DropViewQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*DropViewQuery) GetModel

func (q *DropViewQuery) GetModel() Model

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 Error struct {
	Code       int32
	Name       string
	Message    string
	StackTrace string
	// contains filtered or unexported fields
}

func (*Error) Error

func (exc *Error) Error() string

type Ident

type Ident = chschema.Ident

type InValues

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

func In

func In(slice any) InValues

func (InValues) AppendQuery

func (in InValues) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

type InsertQuery

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

func NewInsertQuery

func NewInsertQuery(db *DB) *InsertQuery

func (*InsertQuery) AppendNamedArg

func (q *InsertQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*InsertQuery) AppendQuery

func (q *InsertQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

func (*InsertQuery) Column

func (q *InsertQuery) Column(columns ...string) *InsertQuery

func (*InsertQuery) ColumnExpr

func (q *InsertQuery) ColumnExpr(query string, args ...any) *InsertQuery

func (*InsertQuery) DB

func (q *InsertQuery) DB() *DB

func (*InsertQuery) ExcludeColumn

func (q *InsertQuery) ExcludeColumn(columns ...string) *InsertQuery

func (*InsertQuery) Exec

func (q *InsertQuery) Exec(ctx context.Context) (sql.Result, error)

func (*InsertQuery) GetModel

func (q *InsertQuery) GetModel() Model

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

func (in ListValues) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

type Model

type Model = chschema.Model

type Name

type Name = chschema.Name

type Option

type Option func(db *DB)

func WithAddr

func WithAddr(addr string) Option

WithAddr configures TCP host:port.

func WithAutoCreateDatabase

func WithAutoCreateDatabase(enabled bool) Option

func WithCluster

func WithCluster(cluster string) Option

func WithCompression

func WithCompression(enabled bool) Option

WithCompression enables/disables LZ4 compression.

func WithConnMaxIdleTime

func WithConnMaxIdleTime(d time.Duration) Option

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

func WithConnMaxLifetime(d time.Duration) Option

If d <= 0, connections are not closed due to a connection's age.

func WithDSN

func WithDSN(dsn string) Option

func WithDatabase

func WithDatabase(database string) Option

func WithDialTimeout

func WithDialTimeout(timeout time.Duration) Option

WithDialTimeout configures dial timeout for establishing new connections. Default is 5 seconds.

func WithDiscardUnknownColumns

func WithDiscardUnknownColumns() Option

func WithInsecure

func WithInsecure(on bool) Option

func WithMaxRetries

func WithMaxRetries(maxRetries int) Option

WithMaxRetries configures maximum number of retries before giving up. Default is to retry query 2 times.

func WithMaxRetryBackoff

func WithMaxRetryBackoff(backoff time.Duration) Option

WithMaxRetryBackoff configures maximum backoff between each retry. Default is 4 seconds; -1 disables backoff.

func WithMinRetryBackoff

func WithMinRetryBackoff(backoff time.Duration) Option

WithMinRetryBackoff configures minimum backoff between each retry. Default is 250 milliseconds; -1 disables backoff.

func WithPassword

func WithPassword(password string) Option

func WithPoolSize

func WithPoolSize(poolSize int) Option

WithPoolSize configures maximum number of socket connections. Default is 2 connections per every CPU as reported by runtime.NumCPU.

func WithPoolTimeout

func WithPoolTimeout(timeout time.Duration) Option

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 WithQuerySettings(params map[string]any) Option

func WithReadTimeout

func WithReadTimeout(timeout time.Duration) Option

WithReadTimeout configures timeout for socket reads. If reached, commands will fail with a timeout instead of blocking.

func WithTLSConfig

func WithTLSConfig(conf *tls.Config) Option

WithTLSConfig configures TLS config for secure connections.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithUser

func WithUser(user string) Option

func WithWriteTimeout

func WithWriteTimeout(timeout time.Duration) Option

WithWriteTimeout configures timeout for socket writes. If reached, commands will fail with a timeout instead of blocking.

type Query

type Query = chschema.Query

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 NewRawQuery

func NewRawQuery(db *DB, query string, args ...any) *RawQuery

func (*RawQuery) AppendNamedArg

func (q *RawQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*RawQuery) AppendQuery

func (q *RawQuery) AppendQuery(fmter chschema.Formatter, b []byte) ([]byte, error)

func (*RawQuery) DB

func (q *RawQuery) DB() *DB

func (*RawQuery) GetModel

func (q *RawQuery) GetModel() Model

func (*RawQuery) GetTableName

func (q *RawQuery) GetTableName() string

func (*RawQuery) Operation

func (q *RawQuery) Operation() string

func (*RawQuery) Scan

func (q *RawQuery) Scan(ctx context.Context, dest ...any) error

func (*RawQuery) ScanColumns

func (q *RawQuery) ScanColumns(ctx context.Context, dest ...any) error

type Row

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

func (*Row) Err

func (r *Row) Err() error

func (*Row) Scan

func (r *Row) Scan(dest ...any) error

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) Close

func (rs *Rows) Close() error

func (*Rows) ColumnTypes

func (rs *Rows) ColumnTypes() ([]*sql.ColumnType, error)

func (*Rows) Columns

func (rs *Rows) Columns() ([]string, error)

func (*Rows) Err

func (rs *Rows) Err() error

func (*Rows) Next

func (rs *Rows) Next() bool

func (*Rows) NextResultSet

func (rs *Rows) NextResultSet() bool

func (*Rows) Scan

func (rs *Rows) Scan(dest ...any) error

type Safe

type Safe = chschema.Safe

type SelectQuery

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

func NewSelectQuery

func NewSelectQuery(db *DB) *SelectQuery

func (*SelectQuery) AppendNamedArg

func (q *SelectQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*SelectQuery) AppendQuery

func (q *SelectQuery) AppendQuery(fmter chschema.Formatter, b []byte) (_ []byte, err error)

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) DB

func (q *SelectQuery) DB() *DB

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) GetModel

func (q *SelectQuery) GetModel() Model

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) Scan

func (q *SelectQuery) Scan(ctx context.Context, values ...any) error

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 TableModel interface {
	Model

	Table() *chschema.Table
	Block(fields []*chschema.Field) *chschema.Block
}

type TruncateTableQuery

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

func NewTruncateTableQuery

func NewTruncateTableQuery(db *DB) *TruncateTableQuery

func (*TruncateTableQuery) AppendNamedArg

func (q *TruncateTableQuery) AppendNamedArg(fmter chschema.Formatter, b []byte, name string) ([]byte, bool)

func (*TruncateTableQuery) AppendQuery

func (q *TruncateTableQuery) AppendQuery(
	fmter chschema.Formatter, b []byte,
) (_ []byte, err error)

func (*TruncateTableQuery) DB

func (q *TruncateTableQuery) DB() *DB

func (*TruncateTableQuery) Exec

func (q *TruncateTableQuery) Exec(ctx context.Context, dest ...any) (sql.Result, error)

func (*TruncateTableQuery) GetModel

func (q *TruncateTableQuery) GetModel() Model

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

Directories

Path Synopsis
cityhash102
* COPY from https://github.com/zentures/cityhash/
* COPY from https://github.com/zentures/cityhash/

Jump to

Keyboard shortcuts

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