db

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name    string `mapstructure:"DB_NAME"`    // The name of the database
	Host    string `mapstructure:"DB_HOST"`    // The hostname or IP address of the database server
	Port    string `mapstructure:"DB_PORT"`    // The port number on which the database server is listening
	User    string `mapstructure:"DB_USER"`    // The username for authenticating with the database server
	Pass    string `mapstructure:"DB_PASS"`    // The password for authenticating with the database server
	Args    string `mapstructure:"DB_ARGS"`    // Additional arguments for the database connection
	Driver  string `mapstructure:"DB_DRIVER"`  // The database driver to use: postgres, mysql
	Migrate string `mapstructure:"DB_MIGRATE"` // The path to the database migration files
	Url     string // The URL for the database connection (derived from other fields)
}

type Database

type Database struct {
	// contains filtered or unexported fields
}

Database represents a database connection.

func NewDatabae

func NewDatabae(config Config, logr zerolog.Logger) (*Database, *sql.DB, error)

NewConnection creates a new database connection based on the provided configuration. It returns a Database instance and any error encountered during the connection process.

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection.

func (*Database) Migrate

func (d *Database) Migrate() (err error)

Migrate performs database migrations using the provided configuration. It takes a logger, a database connection, and a DBConfig object. It returns an error if any error occurs during migration.

func (*Database) Ping

func (d *Database) Ping() error

Ping database

Jump to

Keyboard shortcuts

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