Documentation ¶
Index ¶
- Constants
- Variables
- func ExtractEnum(data []byte) (intToStringMap map[int16]string, stringToIntMap map[string]int16, err error)
- func FilterSimpleAggregate(chType []byte) []byte
- func IsArray(chType []byte) bool
- func IsDateTime64(chType []byte) bool
- func IsDateTimeWithParam(chType []byte) bool
- func IsDecimal(chType []byte) bool
- func IsEnum16(chType []byte) bool
- func IsEnum8(chType []byte) bool
- func IsFixedString(chType []byte) bool
- func IsLowCardinality(chType []byte) bool
- func IsMap(chType []byte) bool
- func IsMultiPolygon(chType []byte) bool
- func IsNested(chType []byte) bool
- func IsNullable(chType []byte) bool
- func IsNullableLowCardinality(chType []byte) bool
- func IsPoint(chType []byte) bool
- func IsPolygon(chType []byte) bool
- func IsRing(chType []byte) bool
- func IsString(chType []byte) bool
- func IsTuple(chType []byte) bool
- func NestedToArrayType(chType []byte) []byte
- type ColumnData
- type Config
- type DatabaseBuilder
- type Field
- type InsertBuilder
- type Migration
- type MigrationRecord
- type Migrator
- func (m *Migrator) Destroy(ctx context.Context, queryOptions *chconn.QueryOptions) error
- func (m *Migrator) GetMigrations() map[string]MigrationRecord
- func (m *Migrator) Migrate(ctx context.Context, queryOptions *chconn.QueryOptions) error
- func (m *Migrator) RegisterMigration(name string, up func(ctx context.Context, orm *ORM, migrator *Migrator) error, ...) error
- func (m *Migrator) Rollback(ctx context.Context, queryOptions *chconn.QueryOptions) error
- func (m *Migrator) Setup(ctx context.Context, queryOptions *chconn.QueryOptions) error
- type ORM
- func (o *ORM) Close()
- func (o *ORM) Connect() error
- func (o *ORM) CreateDatabase(ctx context.Context, dbName string, useDb bool, ...) (*DatabaseBuilder, error)
- func (o *ORM) DropDatabase(ctx context.Context, dbName string, queryOptions *chconn.QueryOptions) (*DatabaseBuilder, error)
- func (o *ORM) GetConfig() *Config
- func (o *ORM) GetConn() chpool.Pool
- func (o *ORM) GetContext() context.Context
- func (o *ORM) GetDatabaseName() string
- func (o *ORM) GetManager() *models.Manager
- func (o *ORM) GetMigrator() *Migrator
- func (o *ORM) Insert(ctx context.Context, model models.Model, queryOptions *chconn.QueryOptions) (models.Model, *InsertBuilder[models.Model], error)
- type SelectBuilder
- func (s *SelectBuilder[T]) Build() (string, error)
- func (s *SelectBuilder[T]) ColumnByType(chType []byte, arrayLevel int, nullable, lc bool) (column.ColumnBasic, error)
- func (s *SelectBuilder[T]) ExecContext(ctx context.Context, queryOptions *chconn.QueryOptions, ...) error
- func (s *SelectBuilder[T]) GetBuilder() *sql.SelectBuilder
- func (s *SelectBuilder[T]) GetColumnsByChType(b models.Model) ([]column.ColumnBasic, error)
- func (s *SelectBuilder[T]) One(ctx context.Context, queryOptions *chconn.QueryOptions, record T) error
- func (s *SelectBuilder[T]) SQL() string
- func (s *SelectBuilder[T]) Scan(ctx context.Context, queryOptions *chconn.QueryOptions) ([]T, error)
- type TableBuilder
- func (b *TableBuilder[T]) Build() (string, error)
- func (b *TableBuilder[T]) Exec(ctx context.Context) error
- func (b *TableBuilder[T]) ExecContext(ctx context.Context, queryOptions *chconn.QueryOptions, ...) error
- func (b *TableBuilder[T]) GetBuilder() *sql.TableBuilder
- func (b *TableBuilder[T]) SQL() string
- type UpdateBuilder
Constants ¶
View Source
const ( TupleStr = "Tuple(" LenTupleStr = len(TupleStr) PointStr = "Point" )
View Source
const ( ArrayStr = "Array(" LenArrayStr = len(ArrayStr) ArrayTypeStr = "Array(<type>)" NestedStr = "Nested(" LenNestedStr = len(NestedStr) NestedToArrayTube = "Array(Nested(" RingStr = "Ring" )
View Source
const ( Enum8Str = "Enum8(" Enum8StrLen = len(Enum8Str) Enum16Str = "Enum16(" Enum16StrLen = len(Enum16Str) DateTimeStr = "DateTime(" DateTimeStrLen = len(DateTimeStr) DateTime64Str = "DateTime64(" DateTime64StrLen = len(DateTime64Str) DecimalStr = "Decimal(" DecimalStrLen = len(DecimalStr) FixedStringStr = "FixedString(" FixedStringStrLen = len(FixedStringStr) SimpleAggregateStr = "SimpleAggregateFunction(" SimpleAggregateStrLen = len(SimpleAggregateStr) )
View Source
const ( LowCardinalityStr = "LowCardinality(" LenLowCardinalityStr = len(LowCardinalityStr) LowCardinalityTypeStr = "LowCardinality(<type>)" LowCardinalityNullableStr = "LowCardinality(Nullable(" LenLowCardinalityNullableStr = len(LowCardinalityNullableStr) LowCardinalityNullableTypeStr = "LowCardinality(Nullable(<type>))" )
View Source
const ( MapStr = "Map(" LenMapStr = len(MapStr) MapTypeStr = "Map(<key>, <value>)" )
View Source
const ( NullableStr = "Nullable(" LenNullableStr = len(NullableStr) NullableTypeStr = "Nullable(<type>)" )
View Source
const MultiPolygonStr = "MultiPolygon"
View Source
const PolygonStr = "Polygon"
View Source
const (
StringStr = "String"
)
Variables ¶
View Source
var ( ErrNoConfigProvided = errors.New("configuration must be provided") ErrNoHostProvided = errors.New("host must be provided") ErrNoPortProvided = errors.New("port must be provided") ErrNoUsernameProvided = errors.New("username must be provided") ErrNoPasswordProvided = errors.New("password must be provided") ErrNoDatabaseProvided = errors.New("database must be provided") )
View Source
var MultiPolygonMainTypeStr = []byte("Array(Array(Array(Tuple(Float64, Float64))))")
View Source
var PointMainTypeStr = []byte("Tuple(Float64, Float64)")
View Source
var PolygonMainTypeStr = []byte("Array(Array(Tuple(Float64, Float64)))")
View Source
var RingMainTypeStr = []byte("Array(Tuple(Float64, Float64))")
Functions ¶
func ExtractEnum ¶
func FilterSimpleAggregate ¶
func IsDateTime64 ¶
func IsDateTimeWithParam ¶
func IsFixedString ¶
func IsLowCardinality ¶
func IsMultiPolygon ¶
func IsNullable ¶
func NestedToArrayType ¶
Types ¶
type ColumnData ¶
type ColumnData struct {
ChType, Name []byte
}
func SplitNameType ¶
func SplitNameType(b []byte) (ColumnData, error)
func TypesInParentheses ¶
func TypesInParentheses(b []byte) ([]ColumnData, error)
type Config ¶
type Config struct { Host string `json:"host" yaml:"host" env:"GCHM_HOST"` Port int `json:"port" yaml:"port" env:"GCHM_PORT"` Username string `json:"username" yaml:"username" env:"GCHM_USERNAME"` Password string `json:"password" yaml:"password" env:"GCHM_PASSWORD"` Database string `json:"database" yaml:"database" env:"GCHM_DATABASE"` SSLMode string `json:"ssl_mode" yaml:"ssl_mode" env:"GCHM_SSL_MODE"` Insecure bool `json:"insecure" yaml:"insecure" env:"GCHM_INSECURE"` }
type DatabaseBuilder ¶
type DatabaseBuilder struct {
// contains filtered or unexported fields
}
func NewCreateDatabase ¶
func NewDropDatabase ¶
func (*DatabaseBuilder) Build ¶
func (b *DatabaseBuilder) Build() (string, error)
func (*DatabaseBuilder) ExecContext ¶
func (b *DatabaseBuilder) ExecContext(ctx context.Context, queryOptions *chconn.QueryOptions) error
func (*DatabaseBuilder) SQL ¶
func (b *DatabaseBuilder) SQL() string
type InsertBuilder ¶
func (*InsertBuilder[T]) Build ¶
func (b *InsertBuilder[T]) Build() (string, error)
func (*InsertBuilder[T]) ExecContext ¶
func (b *InsertBuilder[T]) ExecContext(ctx context.Context, queryOptions *chconn.QueryOptions, columns ...column.ColumnBasic) error
func (*InsertBuilder[T]) SQL ¶
func (b *InsertBuilder[T]) SQL() string
type Migration ¶
type Migration struct { models.Model `clickhouse:"table:migrations, engine:MergeTree(), order: uuid"` UUID uuid.UUID `clickhouse:"name:uuid, type:UUID, primary:true"` Name string `clickhouse:"name:name, type:String"` Migrated bool `clickhouse:"name:migrated, type:Boolean"` CreatedAt time.Time `clickhouse:"name:created_at, type:DateTime"` UpdatedAt time.Time `clickhouse:"name:updated_at, type:DateTime"` }
type MigrationRecord ¶
type MigrationRecord struct {
// contains filtered or unexported fields
}
type Migrator ¶
type Migrator struct {
// contains filtered or unexported fields
}
func NewMigrator ¶
func (*Migrator) GetMigrations ¶
func (m *Migrator) GetMigrations() map[string]MigrationRecord
func (*Migrator) RegisterMigration ¶
type ORM ¶
type ORM struct {
// contains filtered or unexported fields
}
func (*ORM) CreateDatabase ¶
func (*ORM) DropDatabase ¶
func (*ORM) GetContext ¶
func (*ORM) GetDatabaseName ¶
func (*ORM) GetManager ¶
func (*ORM) GetMigrator ¶
type SelectBuilder ¶
type SelectBuilder[T models.Model] struct { *sql.SelectBuilder // contains filtered or unexported fields }
func (*SelectBuilder[T]) Build ¶
func (s *SelectBuilder[T]) Build() (string, error)
func (*SelectBuilder[T]) ColumnByType ¶
func (s *SelectBuilder[T]) ColumnByType(chType []byte, arrayLevel int, nullable, lc bool) (column.ColumnBasic, error)
func (*SelectBuilder[T]) ExecContext ¶
func (s *SelectBuilder[T]) ExecContext(ctx context.Context, queryOptions *chconn.QueryOptions, columns ...column.ColumnBasic) error
func (*SelectBuilder[T]) GetBuilder ¶
func (s *SelectBuilder[T]) GetBuilder() *sql.SelectBuilder
func (*SelectBuilder[T]) GetColumnsByChType ¶
func (s *SelectBuilder[T]) GetColumnsByChType(b models.Model) ([]column.ColumnBasic, error)
func (*SelectBuilder[T]) One ¶
func (s *SelectBuilder[T]) One(ctx context.Context, queryOptions *chconn.QueryOptions, record T) error
func (*SelectBuilder[T]) SQL ¶
func (s *SelectBuilder[T]) SQL() string
type TableBuilder ¶
func NewCreateTable ¶
func NewDropTable ¶
func (*TableBuilder[T]) Build ¶
func (b *TableBuilder[T]) Build() (string, error)
func (*TableBuilder[T]) ExecContext ¶
func (b *TableBuilder[T]) ExecContext(ctx context.Context, queryOptions *chconn.QueryOptions, columns ...column.ColumnBasic) error
func (*TableBuilder[T]) GetBuilder ¶
func (b *TableBuilder[T]) GetBuilder() *sql.TableBuilder
func (*TableBuilder[T]) SQL ¶
func (b *TableBuilder[T]) SQL() string
type UpdateBuilder ¶
func (*UpdateBuilder[T]) Build ¶
func (b *UpdateBuilder[T]) Build() (string, error)
func (*UpdateBuilder[T]) ExecContext ¶
func (b *UpdateBuilder[T]) ExecContext(ctx context.Context, queryOptions *chconn.QueryOptions, columns ...column.ColumnBasic) error
func (*UpdateBuilder[T]) SQL ¶
func (b *UpdateBuilder[T]) SQL() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.