postgressqlx

package
v0.0.0-...-dc7611c Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("postgressqlxfx",
	fx.Provide(NewSqlxConn, provideConfig),
	fx.Invoke(registerHooks),
)

Module provided to fxlog https://uber-go.github.io/fx/modules.html

Functions

This section is empty.

Types

type PostgresSqlxOptions

type PostgresSqlxOptions struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	User     string `mapstructure:"user"`
	DBName   string `mapstructure:"dbName"`
	SSLMode  bool   `mapstructure:"sslMode"`
	Password string `mapstructure:"password"`
}

type Sqlx

type Sqlx struct {
	SqlxDB          *sqlx.DB
	DB              *sql.DB
	SquirrelBuilder squirrel.StatementBuilderType
	GoquBuilder     *goqu.SelectDataset
	// contains filtered or unexported fields
}

func NewSqlxConn

func NewSqlxConn(cfg *PostgresSqlxOptions) (*Sqlx, error)

NewSqlxConn creates a database connection with appropriate pool configuration and runs migration to prepare database.

Migration will be omitted if appropriate config parameter set.

func (*Sqlx) Close

func (db *Sqlx) Close()

func (*Sqlx) ExecTx

func (db *Sqlx) ExecTx(ctx context.Context, fn func(*Sqlx) error) error

ExecTx executes a transaction with provided function.

Jump to

Keyboard shortcuts

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