gormdb

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Type, Charset, Database, TimeZone string
	Host                              string
	Port                              int32
	User, Password                    string
	Postgres                          PostgresConfig
	Mysql                             MysqlConfig
	Sqlite                            SqliteConfig
	MaxIdleConns, MaxOpenConns        int
	ConnMaxLifetime, ConnMaxIdleTime  time.Duration

	Gorm gorm.Config

	UseGormLogger bool
	Logger        logger.Config

	NamingStrategy schema.NamingStrategy
}

func (*Config) AfterInject

func (c *Config) AfterInject()

AfterInject calls Init to apply defaults after config fields are populated.

func (*Config) BeforeInjectWithRoot

func (c *Config) BeforeInjectWithRoot(conf *initialize.RootConfig)

BeforeInjectWithRoot copies the Debug flag and sets a default charset from the root config.

func (*Config) Build

func (c *Config) Build(dialector gorm.Dialector) (*gorm.DB, error)

Build opens a GORM database with the given dialector, applies Prometheus metrics if enabled, and configures connection pool settings.

func (*Config) Init

func (c *Config) Init()

Init sets database type defaults, charset, port, timezone, SSL mode and Sqlite DSN.

type DB

type DB struct {
	*gorm.DB
	Conf Config
}

func (*DB) Table

func (db *DB) Table(name string) *gorm.DB

Table returns a *gorm.DB scoped to the named table without resetting other clauses.

type MetricsCollectorConfig

type MetricsCollectorConfig struct {
	Prefix        string
	Interval      uint32
	VariableNames []string
}

type MysqlConfig

type MysqlConfig struct {
	ParseTime string
	Loc       string
}

type PostgresConfig

type PostgresConfig struct {
	Schema  string
	SSLMode string
}

type SqliteConfig

type SqliteConfig struct {
	DSN string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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