Versions in this module Expand all Collapse all v0 v0.2.0 Sep 26, 2024 Changes in this version + func Zero[T any]() T type Database + func (db *Database) PeriodicCleanup(ctx context.Context, stmt CleanupStmt) error v0.1.0 Mar 13, 2024 Changes in this version + const MySQL + const PostgreSQL + func CantPerformQuery(err error, q string) error + func IsRetryable(err error) bool + func IsStruct(subject interface{}) bool + func IsUnixAddr(host string) bool + func JoinHostPort(host string, port int) string + func RegisterDrivers(logger logr.Logger) + func TableName(t interface{}) string + type CleanupStmt struct + Column string + PK string + Table string + func (stmt *CleanupStmt) Build(driverName string, limit uint64) string + type ColumnMap struct + func NewColumnMap(mapper *reflectx.Mapper) *ColumnMap + func (m *ColumnMap) Columns(subject any) []string + type Config struct + Database string + Host string + Options Options + Password string + Port int + Type string + User string + func FromYAMLFile(file string) (*Config, error) + func (c *Config) Validate() error + type Database struct + Options Options + func NewFromConfig(c *Config, log logr.Logger) (*Database, error) + func (db *Database) BatchSizeByPlaceholders(n int) int + func (db *Database) BuildDeleteStmt(from interface{}) string + func (db *Database) BuildSelectStmt(table interface{}, columns interface{}) string + func (db *Database) BuildUpsertStmt(subject interface{}) (stmt string, placeholders int) + func (db *Database) BulkExec(ctx context.Context, query string, count int, sem *semaphore.Weighted, ...) error + func (db *Database) CleanupOlderThan(ctx context.Context, stmt CleanupStmt, count uint64, olderThan time.Time, ...) (uint64, error) + func (db *Database) Connect() bool + func (db *Database) DeleteStreamed(ctx context.Context, from interface{}, ids <-chan interface{}, ...) error + func (db *Database) GetSemaphoreForTable(table string) *semaphore.Weighted + func (db *Database) NamedBulkExec(ctx context.Context, query string, count int, sem *semaphore.Weighted, ...) error + func (db *Database) UpsertStreamed(ctx context.Context, entities <-chan interface{}, features ...Feature) error + func (db *Database) YieldAll(ctx context.Context, factoryFunc func() (interface{}, error), query string, ...) (<-chan interface{}, <-chan error) + type Driver struct + Logger logr.Logger + func (d Driver) OpenConnector(name string) (driver.Connector, error) + type Feature func(*Features) + func WithBlocking() Feature + func WithCascading() Feature + func WithOnSuccess(fn com.ProcessBulk[any]) Feature + type Features struct + func NewFeatures(features ...Feature) *Features + type HasRelations interface + Relations func() []Relation + type OnSuccess func(ctx context.Context, affectedRows []T) (err error) + type Options struct + MaxConnections int + MaxConnectionsPerTable int + MaxPlaceholdersPerStatement int + MaxRowsPerTransaction int + func (o *Options) Validate() error + type PgSQLDriver struct + func (PgSQLDriver) OpenConnector(name string) (driver.Connector, error) + type Quoter struct + func NewQuoter(db *sqlx.DB) *Quoter + func (q *Quoter) QuoteColumns(columns []string) string + func (q *Quoter) QuoteIdentifier(identifier string) string + type Relation interface + CascadeDelete func() bool + ForeignKey func() string + SetForeignKey func(fk string) + StreamInto func(context.Context, chan interface{}) error + TableName func() string + WithoutCascadeDelete func() + func HasMany[T any](entities []T, options ...RelationOption) Relation + func HasOne[T any](entity T, options ...RelationOption) Relation + type RelationOption func(r Relation) + func WithForeignKey(fk string) RelationOption + func WithoutCascadeDelete() RelationOption + type RetryConnector struct + func (c RetryConnector) Connect(ctx context.Context) (driver.Conn, error) + func (c RetryConnector) Driver() driver.Driver + type TableNamer interface + TableName func() string + type UUID struct + func (uuid UUID) Value() (driver.Value, error) + type Upserter interface + Upsert func() interface{}