gormx

package
v0.0.33 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package gormx - an extension of gorm library. This package loads configurations from cfgx module and create a global gorm.DB object. See Config for more information about the configuration options.

Index

Constants

View Source
const (
	KeyDsn      = "server.database.dsn"
	KeyUsername = "server.database.username"
	KeyPassword = "server.database.password"
	KeyHost     = "server.database.host"
	KeyPort     = "server.database.port"
	KeyDatabase = "server.database.database"
	KeyDebug    = "server.database.debug"
)

Variables

View Source
var (
	DB *gorm.DB
)

Functions

func NewDB added in v0.0.7

func NewDB(cfg *Config) (*gorm.DB, error)

NewDB - opens and generates a new gorm.DB with given configuration.

Types

type Config

type Config struct {
	Dsn      string
	Username string
	Password string
	Host     string
	Port     string
	Database string
	Debug    bool
}
var (
	Cfg    *Config
	DefCfg = &Config{
		Port:  "3306",
		Debug: false,
	}
)

Jump to

Keyboard shortcuts

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