database

package
v0.0.24 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaskSecret

func MaskSecret(dsn string) string

Types

type DB

type DB interface {
	QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)
	BeginTransaction(ctx context.Context) (Transaction, error)
	Close() error
}

func NewDatabase

func NewDatabase(dsn string) (DB, error)

type Database

type Database struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func (*Database) BeginTransaction

func (d *Database) BeginTransaction(ctx context.Context) (Transaction, error)

func (*Database) ExecContext

func (d *Database) ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)

func (*Database) QueryRowsContext

func (d *Database) QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)

type Transaction

type Transaction interface {
	QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)
	ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)
	Rollback() error
	Commit() error
}

type Tx

type Tx struct {
	*sqlx.Tx
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) ExecContext

func (t *Tx) ExecContext(ctx context.Context, query string, args ...interface{}) (int64, error)

func (*Tx) QueryRowsContext

func (t *Tx) QueryRowsContext(ctx context.Context, query string, args ...interface{}) ([]map[string]interface{}, error)

func (*Tx) Rollback

func (t *Tx) Rollback() error

Jump to

Keyboard shortcuts

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