database

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewConnection

func NewConnection(config *Config, environment string) (*gorm.DB, error)

NewConnection returns a new Gorm database connection.

Types

type Config

type Config struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	Database string `mapstructure:"database"`
	Pool     int    `mapstructure:"pool"`
	Timeout  string `mapstructure:"timeout"`
}

Config is the database connection configuration.

func NewConfig

func NewConfig() (*Config, error)

NewConfig returns a new Config instance.

type ConnectionDetails

type ConnectionDetails struct {
	Dialect  string
	Username string
	Password string
	Host     string
	Port     int
	Database string
	Encoding string
	Timeout  string
	Pool     int
}

ConnectionDetails represents database connection details.

func NewConnectionDetails

func NewConnectionDetails(config *Config) ConnectionDetails

NewConnectionDetails creates a new ConnectionDetails struct from a DB configuration.

func (ConnectionDetails) String

func (cd ConnectionDetails) String() string

String builds a connection string from a database Config.

func (ConnectionDetails) StringWithoutDB

func (cd ConnectionDetails) StringWithoutDB() string

StringWithoutDB builds a connection string from a database Config without the database.

Jump to

Keyboard shortcuts

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