database

package
v0.0.0-...-400441b Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB interface {
	// Migrate runs the auto migration for the database.
	Migrate() error
	// DB returns the underlying gorm.DB connection.
	DB() *gorm.DB
	// Close closes the database connection.
	Close() error
}

DB is an interface that defines the methods for the GORM database connection.

func New

func New(cfg *config.Database) (DB, error)

New initializes the database connection based on the configuration.

type Mysql

type Mysql struct {
	Conn *gorm.DB
	// contains filtered or unexported fields
}

Mysql is a wrapper for GORM mysql driver

func (*Mysql) Close

func (m *Mysql) Close() error

Close closes the database connection.

func (*Mysql) DB

func (m *Mysql) DB() *gorm.DB

DB returns the underlying database connection.

func (*Mysql) Migrate

func (m *Mysql) Migrate() error

Migrate runs the auto migration for the database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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