database

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 15 Imported by: 0

README

Database

Database is a lib to simplify the database connection.

Installation

go get github.com/facily-tech/go-core/database

Documentation

Overview

Package database help us to connect to the database using the gorm library and with tracing.

Index

Constants

View Source
const (
	// DBPrefix is the prefix for all environment variables related to the database.
	DBPrefix = "DB_"
	// PostgresDriverName is the name of the postgres driver.
	PostgresDriverName = "pgx"
	// MySQLDriverName is the name of the mysql driver.
	MySQLDriverName = "mysql"
	// Postgres is the enum for postgres database.
	Postgres database = "postgres"
	// MySQL is the enum for mysql database.
	MySQL database = "mysql"
)

Variables

This section is empty.

Functions

func InitDB

func InitDB(database database, gormConfig *gorm.Config) (*gorm.DB, *sql.DB, error)

InitDB initializes a new database connection.

func InitDBWithPrefix added in v0.2.0

func InitDBWithPrefix(database database, gormConfig *gorm.Config, dbPrefix string) (*gorm.DB, *sql.DB, error)

InitDBWithPrefix initializes a new database connection with a prefix.

func InitMongoDB added in v0.2.0

func InitMongoDB() (*mongo.Client, error)

InitMongoDB initializes a new mongo database connection.

func InitMongoDBWithPrefix added in v0.2.0

func InitMongoDBWithPrefix(dbPrefix string) (*mongo.Client, error)

InitMongoDBWithPrefix initializes a new mongo database connection with a prefix.

Types

This section is empty.

Jump to

Keyboard shortcuts

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