database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 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) Delete

func (d *Database) Delete(query string, args ...any) (int64, 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)

func (*Database) Update

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

func (*Database) UpdateContext

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

type Option

type Option func(*Database)

func WithMaxConns

func WithMaxConns(count int) Option

func WithMaxIdle

func WithMaxIdle(count int) 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) Delete

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

func (*Tx) DeleteContext

func (t *Tx) DeleteContext(ctx context.Context, query string, args ...any) (int64, 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)

func (*Tx) Update

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

func (*Tx) UpdateContext

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

Jump to

Keyboard shortcuts

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