db

package
v0.0.0-...-0089d1b Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset       = "\033[0m"
	Red         = "\033[31m"
	Green       = "\033[32m"
	Yellow      = "\033[33m"
	Blue        = "\033[34m"
	Magenta     = "\033[35m"
	Cyan        = "\033[36m"
	White       = "\033[37m"
	BlueBold    = "\033[34;1m"
	MagentaBold = "\033[35;1m"
	RedBold     = "\033[31;1m"
	YellowBold  = "\033[33;1m"
)

Colors

View Source
const LatestMigrationFile = "./db/migrations.latest"

Variables

View Source
var DB *gorm.DB
View Source
var ErrRecordNotFound = errors.New("record not found")

ErrRecordNotFound record not found error

View Source
var (
	// RecorderParamsFilter defaults to no-op, allows to be run-over by a different implementation
	RecorderParamsFilter = func(ctx context.Context, sql string, params ...interface{}) (string, []interface{}) {
		return sql, params
	}
)

Functions

func Close

func Close() error

Close closes global database connection, DB

func Connect

func Connect() error

Connect initializes global database connection, DB

func GetUrl

func GetUrl() string

GetUrl Get database config and return url

func MigrateDB

func MigrateDB(dbURL string, direction string, steps ...int) error

MigrateDB runs migrations up or down with amount to run. Omit "steps" to run all migrations.

func NewDBLogger

func NewDBLogger(config DBLogConfig) logger.Interface

New initialize logger

Types

type DBLogConfig

type DBLogConfig struct {
	SlowThreshold              time.Duration
	Colorful                   bool
	IgnoreRecordNotFoundError  bool
	IgnoreContextCanceledError bool
	IgnoreDuplicatedKeyError   bool
	ParameterizedQueries       bool
	LogLevel                   logger.LogLevel
	// contains filtered or unexported fields
}

Config logger config

Jump to

Keyboard shortcuts

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