sql

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectDB

func ConnectDB(cfg *config.Env, log *log.Logger) (*gorm.DB, error)

func ConnectMysql

func ConnectMysql(cfg *config.Env, log *log.Logger) (*gorm.DB, error)

ConnectMysql establishes a MySQL database connection

func ConnectPostgresql

func ConnectPostgresql(cfg *config.Env, log *log.Logger) (*gorm.DB, error)

ConnectPostgresql establishes a PostgreSQL database connection

Types

type Sql

type Sql struct {
	GormDb *gorm.DB
	// contains filtered or unexported fields
}

func NewSql

func NewSql(cfg *config.Env, log *log.Logger, gormDB *gorm.DB) *Sql

func (*Sql) Begin

func (pkg *Sql) Begin() (*gorm.DB, error)

Begin starts a new transaction

func (*Sql) Close

func (pkg *Sql) Close() error

Close closes the database connection

func (*Sql) Commit

func (pkg *Sql) Commit(tx *gorm.DB) error

Commit commits a transaction

func (*Sql) HealthCheck

func (pkg *Sql) HealthCheck() error

HealthCheck verifies the database connection

func (*Sql) Migrate

func (pkg *Sql) Migrate(models ...interface{}) error

Migrate performs database migrations

func (*Sql) Rollback

func (pkg *Sql) Rollback(tx *gorm.DB)

Rollback rolls back a transaction

func (*Sql) Transaction

func (pkg *Sql) Transaction(fn func(tx *gorm.DB) error) error

Transaction executes a function within a transaction

func (*Sql) WithContext

func (pkg *Sql) WithContext(ctx context.Context) *gorm.DB

WithContext returns a database instance with context

Jump to

Keyboard shortcuts

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