Documentation
¶
Overview ¶
Package database provides database connection management.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectWithConfig ¶
ConnectWithConfig establishes a database connection using the provided configuration.
Types ¶
type DBConfig ¶
type DBConfig struct {
Driver string
Host string
Port string
Name string
User string
Password string
SSLMode string
MaxOpenConns int
MaxIdleConns int
ConnMaxLifetime time.Duration
ConnMaxIdleTime time.Duration
}
DBConfig holds database connection configuration.
func NewDBConfig ¶
func NewDBConfig() DBConfig
NewDBConfig reads database configuration from environment variables.
func NewReadDBConfig ¶
func NewReadDBConfig() DBConfig
NewReadDBConfig reads read-replica configuration from DB_READ_* environment variables. Each setting falls back to the corresponding DB_* value, then to the same defaults used by NewDBConfig.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver holds separate database connections for write and read operations.
func NewResolver ¶
NewResolver creates a Resolver with the given writer and reader connections. If reads should go to the same database, pass the same *gorm.DB for both.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package migrations provides a file-based migration engine for GORM.
|
Package migrations provides a file-based migration engine for GORM. |
|
Package seeders provides a registry-based database seeding system.
|
Package seeders provides a registry-based database seeding system. |