sql

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2025 License: MIT Imports: 10 Imported by: 0

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