Documentation ¶
Overview ¶
Package database help us to connect to the database using the gorm library and with tracing.
Index ¶
- Constants
- func InitDB(database database, gormConfig *gorm.Config) (*gorm.DB, *sql.DB, error)
- func InitDBWithPrefix(database database, gormConfig *gorm.Config, dbPrefix string) (*gorm.DB, *sql.DB, error)
- func InitMongoDB() (*mongo.Client, error)
- func InitMongoDBWithPrefix(dbPrefix string) (*mongo.Client, error)
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 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
InitMongoDB initializes a new mongo database connection.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.