Documentation
¶
Index ¶
- func CollectColumnNames(v reflect.Value, prefix string, columns *[]string)
- func CollectFields(v reflect.Value, prefix string, fieldMap map[string]reflect.Value)
- func GetColumnNames(dest interface{}) ([]string, error)
- func StructFieldsPointers(strct interface{}, columns []string) ([]interface{}, error)
- type DB
- type TxWrapper
- func (tw *TxWrapper) Commit(ctx context.Context) error
- func (tw *TxWrapper) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
- func (tw *TxWrapper) Get(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error
- func (tw *TxWrapper) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (tw *TxWrapper) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (tw *TxWrapper) Rollback(ctx context.Context) error
- func (tw *TxWrapper) Select(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error
- type Wrapper
- func (w *Wrapper) Begin(ctx context.Context) (*TxWrapper, error)
- func (w *Wrapper) BeginTx(ctx context.Context, txOptions pgx.TxOptions) (*TxWrapper, error)
- func (w *Wrapper) Exec(ctx context.Context, sql string, args ...interface{}) (pgconn.CommandTag, error)
- func (w *Wrapper) Get(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error
- func (w *Wrapper) Query(ctx context.Context, sql string, args ...interface{}) (pgx.Rows, error)
- func (w *Wrapper) QueryRow(ctx context.Context, sql string, args ...interface{}) pgx.Row
- func (w *Wrapper) Select(ctx context.Context, dest interface{}, sqlStr string, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectColumnNames ¶
CollectColumnNames recursively collects column names from the struct fields.
GetColumnNames no longer calls this directly (see CollectFields), but it is kept with its original signature for backward compatibility with any external callers.
func CollectFields ¶
CollectFields recursively collects fields, including nested structs.
Get and Select no longer call this directly (they use a cached, type-based field resolver instead), but it is kept with its original signature for backward compatibility with any external callers.
func GetColumnNames ¶
GetColumnNames is a recursive function to get a list of column names from the struct
func StructFieldsPointers ¶
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 ¶
TxWrapper is a wrapper for transactions
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
type Wrapper ¶
Wrapper is a structure that contains a connection pool to the database
func NewWrapper ¶
NewWrapper creates a new wrapper with a connection pool
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