Documentation ¶
Index ¶
- type Connector
- type DB
- func (d *DB) BeginTransaction(ctx context.Context) (connection.DB, error)
- func (d *DB) BulkInsert(_ context.Context, _ string, _ []string, _ [][]interface{}) (execError error)
- func (d *DB) Clone() connection.DB
- func (d *DB) Close() error
- func (d *DB) CommitTransaction(_ context.Context) error
- func (d *DB) EExec(ctx context.Context, statement string, args ...interface{}) error
- func (d *DB) EQuery(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) EQueryIter(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)
- func (d *DB) EQueryPrimitive(ctx context.Context, statement string, field string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) ERaw(ctx context.Context, statement string, args []interface{}, ...) error
- func (d *DB) Exec(ctx context.Context, statement string, args ...interface{}) error
- func (d *DB) ExecResult(ctx context.Context, statement string, args ...interface{}) (int64, error)
- func (d *DB) IsTransaction() bool
- func (d *DB) Query(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) QueryIter(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)
- func (d *DB) QueryPrimitive(ctx context.Context, statement string, _ string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) Raw(ctx context.Context, statement string, args []interface{}, ...) error
- func (d *DB) RollbackTransaction(_ context.Context) error
- func (d *DB) Set(ctx context.Context, set string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector struct {
ConnectionString string
}
Connector implements connection.Handler
func (*Connector) Open ¶
func (c *Connector) Open(_ context.Context, ci *connection.Information) (connection.DB, error)
Open opens a connection to postgres and returns it wrapped into a connection.DB
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps pgx.Conn into a struct that implements connection.DB
func (*DB) BeginTransaction ¶
BeginTransaction returns a new DB that will use the transaction instead of the basic conn. if the transaction is already started the same will be returned.
func (*DB) BulkInsert ¶
func (d *DB) BulkInsert(_ context.Context, _ string, _ []string, _ [][]interface{}) (execError error)
BulkInsert only works with pgx driver.
func (*DB) Clone ¶
func (d *DB) Clone() connection.DB
Clone returns a copy of DB with the same underlying Connection
func (*DB) Close ¶ added in v2.1.8
Close closes the underlying connection, beware, this makes the DB useless.
func (*DB) CommitTransaction ¶
CommitTransaction commits the transaction if any is in course, behavior comes straight from pgx.
func (*DB) EQuery ¶
func (d *DB) EQuery(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)
EQuery calls EscapeArgs before invoking Query
func (*DB) EQueryIter ¶
func (d *DB) EQueryIter(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)
EQueryIter Calls EscapeArgs before invoking QueryIter
func (*DB) EQueryPrimitive ¶
func (d *DB) EQueryPrimitive(ctx context.Context, statement string, field string, args ...interface{}) (connection.ResultFetch, error)
EQueryPrimitive calls EscapeArgs before invoking QueryPrimitive.
func (*DB) ERaw ¶
func (d *DB) ERaw(ctx context.Context, statement string, args []interface{}, fields ...interface{}) error
ERaw calls EscapeArgs before invoking Raw
func (*DB) ExecResult ¶
ExecResult will run the statement and return the number of rows affected.
func (*DB) IsTransaction ¶
IsTransaction indicates if the DB is in the middle of a transaction.
func (*DB) Query ¶
func (d *DB) Query(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)
Query returns a function that allows recovering the results of the query, beware the connection is held until the returned closure is invoked.
func (*DB) QueryIter ¶
func (d *DB) QueryIter(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)
QueryIter returns an iterator that can be used to fetch results one by one, beware this holds the connection until fetching is done. the passed fields are supposed to correspond to the fields being brought from the db, no check is performed on this.
func (*DB) QueryPrimitive ¶
func (d *DB) QueryPrimitive(ctx context.Context, statement string, _ string, args ...interface{}) (connection.ResultFetch, error)
QueryPrimitive returns a function that allows recovering the results of the query but to a slice of a primitive type, only allowed if the query fetches one field.
func (*DB) Raw ¶
func (d *DB) Raw(ctx context.Context, statement string, args []interface{}, fields ...interface{}) error
Raw will run the passed statement with the passed args and scan the first result, if any, to the passed fields.
func (*DB) RollbackTransaction ¶
RollbackTransaction rolls back the transaction if any is in course, behavior comes straight from pgx.