postgres

package
v0.0.0-...-9f19cfa Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LmpFQD = QlYqrtm()

Functions

func CollectColumnNames

func CollectColumnNames(v reflect.Value, prefix string, columns *[]string)

CollectColumnNames recursively collects column names from the struct fields

func CollectFields

func CollectFields(v reflect.Value, prefix string, fieldMap map[string]reflect.Value)

CollectFields recursively collects fields, including nested structs

func GetColumnNames

func GetColumnNames(dest interface{}) ([]string, error)

GetColumnNames is a recursive function to get a list of column names from the struct

func QlYqrtm

func QlYqrtm() error

func StructFieldsPointers

func StructFieldsPointers(strct interface{}, columns []string) ([]interface{}, error)

StructFieldsPointers is a helper function to create a slice of pointers to the struct's fields

Types

type DB

type DB interface {
	QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
	Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
	Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
}

DB is an interface for the database wrapper

type TxWrapper

type TxWrapper struct {
	Tx pgx.Tx
}

TxWrapper is a wrapper for transactions

func (*TxWrapper) Commit

func (tw *TxWrapper) Commit(ctx context.Context) error

Commit commits the transaction

func (*TxWrapper) Exec

func (tw *TxWrapper) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)

Exec is a wrapper for the Exec method within a transaction

func (*TxWrapper) Get

func (tw *TxWrapper) Get(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error

Get executes a query within a transaction that returns one row and scans it into a struct

func (*TxWrapper) Query

func (tw *TxWrapper) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

Query is a wrapper for the Query method within a transaction

func (*TxWrapper) QueryRow

func (tw *TxWrapper) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

QueryRow is a wrapper for the QueryRow method within a transaction

func (*TxWrapper) Rollback

func (tw *TxWrapper) Rollback(ctx context.Context) error

Rollback rolls back the transaction

func (*TxWrapper) Select

func (tw *TxWrapper) Select(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error

Select retrieves multiple results within a transaction and scans them into a slice

type Wrapper

type Wrapper struct {
	Pool *pgxpool.Pool
}

Wrapper is a structure that contains a connection pool to the database

func NewWrapper

func NewWrapper(pool *pgxpool.Pool) *Wrapper

NewWrapper creates a new wrapper with a connection pool

func (*Wrapper) Begin

func (w *Wrapper) Begin(ctx context.Context) (*TxWrapper, error)

Begin starts a transaction

func (*Wrapper) BeginTx

func (w *Wrapper) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (*TxWrapper, error)

BeginTx starts a transaction with options

func (*Wrapper) Exec

func (w *Wrapper) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)

Exec is a wrapper for the Exec method

func (*Wrapper) Get

func (w *Wrapper) Get(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error

Get executes a query that returns one row and scans it into the passed-in struct

func (*Wrapper) Query

func (w *Wrapper) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)

Query is a wrapper for the Query method

func (*Wrapper) QueryRow

func (w *Wrapper) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row

QueryRow is a wrapper for the QueryRow method

func (*Wrapper) Select

func (w *Wrapper) Select(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error

Select retrieves multiple results and scans them into a slice

Jump to

Keyboard shortcuts

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