db

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2026 License: Apache-2.0 Imports: 6 Imported by: 9 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(c Config) (*gorm.DB, error)

OpenDB initializes GORM using the configuration parameters.

Types

type Config

type Config struct {
	Host            string    `yaml:"host"`
	Port            int       `yaml:"port"`
	Username        string    `yaml:"username"`
	Database        string    `yaml:"database"`
	PasswordEnvName string    `yaml:"passwordEnvName"`
	SSL             SSLConfig `yaml:"ssl"`

	// CreateDatabase specifies whether to create the database if it does not exist.
	CreateDatabase bool `yaml:"createDatabase"`
	// OriginalDatabase specifies the original database to connect to before creating the database.
	// If empty, use "template1".
	OriginalDatabase string `yaml:"originalDatabase"`
}

Config specifies the configurations to connect to the database.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration.

type SSLConfig

type SSLConfig struct {
	Mode     string `yaml:"mode"`
	RootCert string `yaml:"rootCert"`
}

SSLConfig specifies the configurations for SSL.

Jump to

Keyboard shortcuts

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