database

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: GPL-3.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MysqlDriver      = "mysql"
	PostgresqlDriver = "postgresql"
	ClickhouseDriver = "clickhouse"
)

Variables

View Source
var GormLoggerLevels = map[string]gormLogger.LogLevel{
	"info":   gormLogger.Info,
	"warn":   gormLogger.Warn,
	"error":  gormLogger.Error,
	"silent": gormLogger.Silent,
}

Functions

func NewClickhouseDialector

func NewClickhouseDialector(dsn string) gorm.Dialector

func NewGormLoggerAdapter

func NewGormLoggerAdapter(lg logger.Logger, cfg gormLogger.Config) gormLogger.Interface

func NewGormProvider

func NewGormProvider(configs Configs) contracts.Provider

func NewMigrateCommands

func NewMigrateCommands(app contracts.Application, mig migorm.Migrater) []*cli.Command

func NewMigraterService

func NewMigraterService(
	app contracts.Application,
	cfg migorm.Config,
	upOnStart bool,
) migorm.Migrater

Types

type Callback

type Callback func(*gorm.DB)

type Config

type Config struct {
	Name   string
	Driver string

	DBHost string
	DBPort string
	DBUser string
	DBPass string
	DBName string

	MigrationsTableName  string
	MigrationsDir        string
	MigrationsRunOnStart bool

	LogLevel      string
	SlowThreshold time.Duration
}

func (*Config) Dialector

func (c *Config) Dialector() gorm.Dialector

func (*Config) IsDefault

func (c *Config) IsDefault() bool

func (*Config) LowerPrefix

func (c *Config) LowerPrefix() string

func (*Config) UpperPrefix

func (c *Config) UpperPrefix() string

type Configs

type Configs []*Config

func (Configs) Default

func (c Configs) Default() *Config

type Connection

type Connection interface {
	DB() *gorm.DB
	Register(cb Callback)
	IsConnected() bool
	Connect()
	Close()
}

func NewGormConnection

func NewGormConnection(dialector gorm.Dialector, gormCfg *gorm.Config, log logger.Logger) Connection

type ConnectionPool

type ConnectionPool interface {
	Default() Connection
	Get(name string) Connection
}

type ConnectionRegistry

type ConnectionRegistry interface {
	ConnectionPool
	Register(name string, conn Connection)
}

func NewConnectionRegistry

func NewConnectionRegistry() ConnectionRegistry

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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