database

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DB_DSN                 = "datasource.dsn"
	DB_URL_KEY             = "datasource.url"
	DB_USERNAME_KEY        = "datasource.username"
	DB_PWD_KEY             = "datasource.password"
	DB_CONN_MAX_LIFE_TIME  = "datasource.connMaxLifetime"
	DB_MAX_IDLE_CONNS      = "datasource.maxIdleConns"
	DB_MAX_OPEN_CONNS      = "datasource.maxOpenConns"
	DB_QueryFields         = "datasource.queryFields"
	DB_TYPE                = "datasource.type"
	DefaultConnMaxLifetime = 30 * time.Minute
	DefaultMaxIdleConns    = 10
	DefaultMaxOpenConns    = 50
	DB_TYPE_MYSQL          = "mysql"
)

Variables

This section is empty.

Functions

func CreateInsertSql

func CreateInsertSql(tableName string, kv map[string]interface{}) (sql string, values []interface{})

func Expr

func Expr(expr string, args ...interface{}) clause.Expr

func Get

func Get() *gorm.DB

func GetWithContext

func GetWithContext(ctx context.Context) *gorm.DB

func InitDataSource

func InitDataSource(option option.Option, dialector Dialector) *gorm.DB

func InitDefault

func InitDefault(dialector Dialector)

根据项目env初始化

func InitDefaultWithOption

func InitDefaultWithOption(option option.Option, dialector Dialector)

func IsDuplicatedKeyError added in v0.9.3

func IsDuplicatedKeyError(err error) bool

func Transaction

func Transaction(ctx context.Context, fc func(txctx context.Context) error) error

Types

type Dialector added in v0.9.0

type Dialector interface {
	New(option option.Option) gorm.Dialector
}

Directories

Path Synopsis
dialectors

Jump to

Keyboard shortcuts

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