db

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultQueryTimeout = 30 * time.Second
View Source
var LogLevel string

LogLevel is the log level for gorm logger

Functions

func BindGoFlags

func BindGoFlags()

BindGoFlags binds database flags to the provided flag set

func DefaultGormConfig

func DefaultGormConfig() *gormDriver.Config

DefaultGormConfig returns the default GORM configuration

func Delete

func Delete(ctx dbContext.Context, model Table) error

Delete performs a soft delete on the given model

func InitDB

func InitDB(config api.Config) (*dbContext.Context, error)

InitDB creates a context with database connections Note: Does NOT check for migrations - consumers should verify migrations separately

func NewDB

func NewDB(connection string) (*sql.DB, error)

NewDB creates a new sql.DB connection

func NewGorm

func NewGorm(connection string, config *gorm.Config) (*gorm.DB, error)

NewGorm creates a new Gorm DB connection using the provided connection string

func NewPgxPool

func NewPgxPool(connection string) (*pgxpool.Pool, error)

NewPgxPool creates a new pgx connection pool with OpenTelemetry tracing

func Now

func Now() clause.Expr

Now returns a SQL expression for the current timestamp

func SetupDB

func SetupDB(connectionString string, logName string) (gormDB *gormDriver.DB, pgxPool *pgxpool.Pool, err error)

SetupDB creates database connections (gorm.DB and pgxpool.Pool) Note: This does NOT run migrations - consumers should handle migrations separately

Types

type Table

type Table interface {
	TableName() string
}

Table interface for models with TableName

Jump to

Keyboard shortcuts

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