db

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = Config{
	Dialect:  "mysql",
	Host:     "localhost",
	Port:     3306,
	User:     "root",
	Password: "",
	Database: "db",
}
View Source
var Module = fx.Module(
	"db",
	fx.Decorate(func(log *zap.Logger) *zap.Logger {
		return log.Named("db")
	}),
	fx.Provide(
		New,
		NewSQL,
	),
)

Functions

func AutoMigrate added in v1.4.0

func AutoMigrate(params CommandMigrateParams) error

func Migrate added in v1.4.0

func Migrate(params GooseMigrateParams) error

func New

func New(params Params) (*gorm.DB, error)

func NewSQL added in v1.3.0

func NewSQL(config Config) (*sql.DB, error)

func RegisterGoose added in v1.4.0

func RegisterGoose(storage GooseStorage)

func RegisterMigration added in v1.4.0

func RegisterMigration(migrator Migrator)

Types

type CommandMigrateParams

type CommandMigrateParams struct {
	fx.In

	Logger *zap.Logger
	DB     *gorm.DB
	Shut   fx.Shutdowner
}

type Config

type Config struct {
	Dialect  string
	Host     string
	Port     int
	User     string
	Password string
	Database string
	Timezone string
}

type GooseMigrateParams added in v1.3.0

type GooseMigrateParams struct {
	fx.In

	Args cli.Args

	Config Config

	Logger *zap.Logger
	DB     *sql.DB
	Shut   fx.Shutdowner
}

type GooseStorage added in v1.3.0

type GooseStorage fs.FS

type Migrator

type Migrator func(*gorm.DB) error

type Params

type Params struct {
	fx.In

	Logger *zap.Logger
	Config Config
	SQL    *sql.DB
	LC     fx.Lifecycle
}

Jump to

Keyboard shortcuts

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