pgxquery

package
v0.0.0-...-44d9088 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NotFound

func NotFound(err error) bool

NotFound is a helper function to check if an error is `pgx.ErrNoRows`.

Types

type API

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

func NewAPI

func NewAPI(dbqueryAPI *dbquery.API) (*API, error)

NewAPI creates new API instance from dbquery.API instance.

func (*API) Exec

func (api *API) Exec(ctx context.Context, db Querier, query string, args ...interface{}) (pgconn.CommandTag, error)

Exec is a high-level function that sends an executable action to the database

func (*API) ExecNamed

func (api *API) ExecNamed(ctx context.Context, db Querier, query string, arg interface{}) (pgconn.CommandTag, error)

ExecNamed is a high-level function that sends an executable action to the database with named parameters

func (*API) Get

func (api *API) Get(ctx context.Context, db Querier, dst interface{}, query string, args ...interface{}) error

Get is a high-level function that queries rows from Querier and calls the ScanOne function. See ScanOne for details.

func (*API) GetNamed

func (api *API) GetNamed(ctx context.Context, db Querier, dst interface{}, query string, arg interface{}) error

GetNamed is a high-level function that queries rows from Querier and calls the ScanOne function. See ScanOne for details.

func (*API) PrepareNamed

func (api *API) PrepareNamed(query string, assertableStruct ...interface{}) (*PreparedQuery, error)

func (*API) Query

func (api *API) Query(ctx context.Context, db Querier, query string, args ...interface{}) (pgx.Rows, error)

Query is a wrapper around pgx's own query method

func (*API) QueryNamed

func (api *API) QueryNamed(ctx context.Context, db Querier, query string, arg interface{}) (pgx.Rows, error)

QueryNamed is a high-level function that is used to retrieve pgx.Rows from the database with named parameters

func (*API) ScanAll

func (api *API) ScanAll(dst interface{}, rows pgx.Rows) error

ScanAll is a wrapper around the dbscan.ScanAll function. See dbscan.ScanAll for details.

func (*API) ScanOne

func (api *API) ScanOne(dst interface{}, rows pgx.Rows) error

ScanOne is a wrapper around the dbscan.ScanOne function. See dbscan.ScanOne for details. If no rows are found it returns a pgx.ErrNoRows error.

func (*API) ScanRow

func (api *API) ScanRow(dst interface{}, rows pgx.Rows) error

ScanRow is a wrapper around the dbscan.ScanRow function. See dbscan.ScanRow for details.

func (*API) Select

func (api *API) Select(ctx context.Context, db Querier, dst interface{}, query string, args ...interface{}) error

Select is a high-level function that queries rows from Querier and calls the ScanAll function. See ScanAll for details.

func (*API) SelectNamed

func (api *API) SelectNamed(ctx context.Context, db Querier, dst interface{}, query string, arg interface{}) error

SelectNamed is a high-level function that queries rows from Querier and calls the ScanAll function. See ScanAll for details.

type PreparedQuery

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

func (*PreparedQuery) ExecNamed

func (pq *PreparedQuery) ExecNamed(ctx context.Context, db Querier, arg interface{}) (pgconn.CommandTag, error)

ExecNamed is a high-level function that sends an executable action to the database with named parameters

func (*PreparedQuery) GetNamed

func (pq *PreparedQuery) GetNamed(ctx context.Context, db Querier, dst interface{}, arg interface{}) error

GetNamed is a high-level function that queries rows from Querier and calls the ScanOne function. See ScanOne for details.

func (*PreparedQuery) QueryNamed

func (pq *PreparedQuery) QueryNamed(ctx context.Context, db Querier, arg interface{}) (pgx.Rows, error)

QueryNamed is a high-level function that is used to retrieve *sql.Rows from the database with named parameters

func (*PreparedQuery) SelectNamed

func (pq *PreparedQuery) SelectNamed(ctx context.Context, db Querier, dst interface{}, arg interface{}) error

SelectNamed is a high-level function that queries rows from Querier and calls the ScanAll function. See ScanAll for details.

type Querier

type Querier interface {
	Query(ctx context.Context, query string, args ...interface{}) (pgx.Rows, error)
	Exec(ctx context.Context, sql string, arguments ...any) (pgconn.CommandTag, error)
}

Querier is something that pgxscan can query and get the pgx.Rows from. For example, it can be: *pgxpool.Pool, *pgx.Conn or pgx.Tx.

type RowsAdapter

type RowsAdapter struct {
	pgx.Rows
}

RowsAdapter makes pgx.Rows compliant with the dbscan.Rows interface. See dbscan.Rows for details.

func NewRowsAdapter

func NewRowsAdapter(rows pgx.Rows) *RowsAdapter

NewRowsAdapter returns a new RowsAdapter instance.

func (RowsAdapter) Close

func (ra RowsAdapter) Close() error

Close implements the dbscan.Rows.Close method.

func (RowsAdapter) Columns

func (ra RowsAdapter) Columns() ([]string, error)

Columns implements the dbscan.Rows.Columns method.

Jump to

Keyboard shortcuts

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