db

package
v0.0.0-...-f07e814 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBops

type DBops interface {
	Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row
	Begin(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

DBops dp ops

type PgDatabase

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

PgDatabase struct with pg pool

func NewPostgres

func NewPostgres(ctx context.Context) (*PgDatabase, error)

NewPostgres create new db

func (PgDatabase) Begin

func (db PgDatabase) Begin(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)

Begin begins transaction

func (PgDatabase) BeginX

func (db PgDatabase) BeginX(ctx context.Context, opts *sql.TxOptions) (*sqlx.Tx, error)

BeginX begins transaction

func (PgDatabase) Close

func (db PgDatabase) Close()

Close closes db

func (PgDatabase) Exec

func (db PgDatabase) Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)

Exec helper

func (PgDatabase) Get

func (db PgDatabase) Get(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Get helper

func (PgDatabase) GetDB

func (db PgDatabase) GetDB() *sqlx.DB

GetDB returns undrlying db

func (PgDatabase) NamedExec

func (db PgDatabase) NamedExec(ctx context.Context, query string, arg interface{}) (sql.Result, error)

NamedExec helper

func (PgDatabase) NamedQuery

func (db PgDatabase) NamedQuery(ctx context.Context, query string, arg interface{}) (*sqlx.Rows, error)

NamedQuery helper

func (PgDatabase) QueryRow

func (db PgDatabase) QueryRow(ctx context.Context, query string, args ...interface{}) *sql.Row

QueryRow helper

func (PgDatabase) QueryRowx

func (db PgDatabase) QueryRowx(ctx context.Context, query string, args ...interface{}) *sqlx.Row

QueryRowx helper

func (PgDatabase) Select

func (db PgDatabase) Select(ctx context.Context, dest interface{}, query string, args ...interface{}) error

Select helper

Jump to

Keyboard shortcuts

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