database

package
v0.0.0-...-a48b4e1 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoDatabaseDsn = errors.New("no database dsn")
)

Functions

func ConnectForTest

func ConnectForTest(ctx context.Context, addr string) (db *gorm.DB, err error)

func IsForeignKeyConstraintError

func IsForeignKeyConstraintError(err error) bool

IsForeignKeyConstraintError reports if the error resulted from a DB FK constraint violation. e.g. parent row does not exist.

func IsUniqueConstraintError

func IsUniqueConstraintError(err error) bool

IsUniqueConstraintError reports if the error resulted from a DB uniqueness constraint violation. e.g. duplicate value in unique index.

func NewGorm

func NewGorm(ctx context.Context, opts ...Option) (db *gorm.DB, err error)

NewGorm

func RunContainerForTest

func RunContainerForTest(ctx context.Context, queriesFile string) (*gnomock.Container, error)

func UpdateID

func UpdateID(db *gorm.DB)

Types

type MysqlOption

type MysqlOption func(*mysqlOptions)

type Option

type Option func(*options)

Option 定义参数项

func WithAutoMigrate

func WithAutoMigrate(autoMigrate bool) Option

WithAutoMigrate 设定 autoMigrate

func WithDebug

func WithDebug(debug bool) Option

WithDebug 设定 debug

func WithDialect

func WithDialect(dialect string) Option

WithDialect 设定 dialect

func WithMysqlCharset

func WithMysqlCharset(charset string) Option

func WithMysqlHost

func WithMysqlHost(host string) Option

func WithMysqlName

func WithMysqlName(name string) Option

func WithMysqlOptions

func WithMysqlOptions(opts ...MysqlOption) Option

WithMysqlOptions 设定 mysqlOptions

func WithMysqlPassword

func WithMysqlPassword(password string) Option

func WithMysqlPort

func WithMysqlPort(port int) Option

func WithMysqlUser

func WithMysqlUser(user string) Option

WithMysqlUser 设定 user

func WithSqliteName

func WithSqliteName(name string) Option

func WithSqliteOptions

func WithSqliteOptions(opts ...SqliteOption) Option

WithSqliteOptions 设定 sqliteOptions

type SqliteOption

type SqliteOption func(*sqliteOptions)

Jump to

Keyboard shortcuts

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