db

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 6 Imported by: 8

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