database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package database provides useful functions for database operations and configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloseDB

func CloseDB(db *gorm.DB) error

CloseDB closes the underlying sql.DB from a gorm.DB.

func NewGORMLogger

func NewGORMLogger() logger.Interface

NewGORMLogger returns a new logger for GORM.

The logger implementation uses zerolog under the hood, and it is initialized with the global zerolog Logger. A zerolog-compatible log level is also set from the global logger.

func OpenDB

func OpenDB(conf config.DB) (*gorm.DB, error)

OpenDB initializes a database session, connecting to the specific database from configuration.

func OpenDBWithoutDBName

func OpenDBWithoutDBName(conf config.DB) (*gorm.DB, error)

OpenDBWithoutDBName initializes a database session ignoring config.DB.DBName.

Among others, it can be useful for special operations such as creating or dropping a database.

Types

This section is empty.

Jump to

Keyboard shortcuts

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