sql

package
v0.0.0-...-2119b44 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: MPL-2.0 Imports: 13 Imported by: 39

Documentation

Index

Constants

View Source
const PGERROR_CODE_UNIQUE_VIOLATION = "23505"

Variables

This section is empty.

Functions

func IsDuplicateKeyError

func IsDuplicateKeyError(err error) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

Types

type Db

type Db interface {
	GetGormDb() *gorm.DB
	Init(model ...interface{}) error
	Connect() error
	ExecuteInTransaction(dbOperation func(tx *gorm.DB) *gorm.DB, nestedFuncs ...func() error) (err error)
	// version 2 of execute in transaction to pass transaction object to nested functions
	ExecuteInTransaction2(dbOperation func(tx *gorm.DB) *gorm.DB, nestedFuncs ...func(tx *gorm.DB) error) (err error)
}

would be better to seaprate migration logic from actuall ORM

func NewDb

func NewDb(dbConfig DbConfig, debugMode bool) Db

func NewDbFromGorm

func NewDbFromGorm(gormDb *gorm.DB, debugMode bool) Db

type DbConfig

type DbConfig interface {
	GetConnString() string
	ChangeDbName(name string) DbConfig
	GetDbName() string
}

Jump to

Keyboard shortcuts

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