database

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// contains filtered or unexported fields
}

func NewDB added in v1.1.0

func NewDB(driverName string, db *sql.DB) *Database

func OpenDB

func OpenDB(driverName, dsn string, ops ...Option) (*Database, error)

func (*Database) BeginTx

func (d *Database) BeginTx() (*Tx, error)

func (*Database) BeginTxCtx added in v1.0.10

func (d *Database) BeginTxCtx(ctx context.Context) (*Tx, error)

func (*Database) Client

func (d *Database) Client() *sql.DB

func (*Database) Close

func (d *Database) Close() error

func (*Database) ExecContext added in v1.3.0

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

func (*Database) Insert

func (d *Database) Insert(query string, args ...any) (int64, error)

func (*Database) InsertContext

func (d *Database) InsertContext(ctx context.Context, query string, args ...any) (int64, error)

func (*Database) Ping

func (d *Database) Ping(ctx context.Context) error

func (*Database) QueryForMap

func (d *Database) QueryForMap(query string, args ...any) (map[string]any, error)

func (*Database) QueryForMapSlice

func (d *Database) QueryForMapSlice(query string, args ...any) ([]map[string]any, error)

func (*Database) QueryMapContext

func (d *Database) QueryMapContext(ctx context.Context, query string, args ...any) (map[string]any, error)

func (*Database) QueryMapSliceContext

func (d *Database) QueryMapSliceContext(ctx context.Context, query string, args ...any) ([]map[string]any, error)

func (*Database) Reset

func (d *Database) Reset(db *sql.DB, dsn string)

type Option

type Option func(*Database)

func WithMaxConns

func WithMaxConns(count int) Option

func WithMaxIdle

func WithMaxIdle(count int) Option

func WithMaxIdleTime added in v1.4.0

func WithMaxIdleTime(ex time.Duration) Option

func WithMaxLifetime

func WithMaxLifetime(ex time.Duration) Option

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Close

func (t *Tx) Close() error

func (*Tx) ExecContext added in v1.3.0

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

func (*Tx) HasError

func (t *Tx) HasError()

func (*Tx) Insert

func (t *Tx) Insert(query string, args ...any) (int64, error)

func (*Tx) InsertContext

func (t *Tx) InsertContext(ctx context.Context, query string, args ...any) (int64, error)

func (*Tx) QueryForMap

func (t *Tx) QueryForMap(query string, args ...any) (map[string]any, error)

func (*Tx) QueryForMapSlice

func (t *Tx) QueryForMapSlice(query string, args ...any) ([]map[string]any, error)

func (*Tx) QueryMapContext

func (t *Tx) QueryMapContext(ctx context.Context, query string, args ...any) (map[string]any, error)

func (*Tx) QueryMapSliceContext

func (t *Tx) QueryMapSliceContext(ctx context.Context, query string, args ...any) ([]map[string]any, error)

Jump to

Keyboard shortcuts

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