Documentation ¶
Index ¶
- func PrefixSearch(str string) string
- type Cond
- type DB
- func (db *DB) AcquireValues() *Values
- func (db *DB) Close()
- func (db *DB) Delete(ctx context.Context, table Identifier, cond QueryEncoder) (count int64, err error)
- func (db *DB) Exec(ctx context.Context, query string, args ...any) (pgconn.CommandTag, error)
- func (db *DB) InsertValues(ctx context.Context, table Identifier, vals *Values, conflictColumns ...string) (count int64, err error)
- func (db *DB) Query(ctx context.Context, query string, args ...any) (pgx.Rows, error)
- func (db *DB) QueryRow(ctx context.Context, query string, args ...any) pgx.Row
- func (db *DB) ReleaseValues(v *Values)
- func (db *DB) Transaction(ctx context.Context, readOnly ...bool) (tx *Tx, err error)
- func (db *DB) UpdateValues(ctx context.Context, table Identifier, vals *Values, cond QueryEncoder) (count int64, err error)
- type Error
- type Identifier
- type MultiAnd
- type MultiOr
- type QueryEncoder
- func Eq(col string, val any) QueryEncoder
- func Gt(col string, val any) QueryEncoder
- func Gte(col string, val any) QueryEncoder
- func In(col string, val any) QueryEncoder
- func Lt(col string, val any) QueryEncoder
- func Lte(col string, val any) QueryEncoder
- func NotEq(col string, val any) QueryEncoder
- func NotIn(col string, val any) QueryEncoder
- func Raw(s string, args ...any) QueryEncoder
- func Search(col, val string, options ...SearchOptions) QueryEncoder
- type SearchOptions
- type Tx
- type Values
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrefixSearch ¶ added in v0.1.0
Example ¶
fmt.Println(PrefixSearch(" hello world "))
Output: hello:* world:*
Types ¶
type Cond ¶
type Cond func(buf *fast.StringBuffer, queryArgs *[]any)
func (Cond) EncodeQuery ¶
func (c Cond) EncodeQuery(buf *fast.StringBuffer, queryArgs *[]any)
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
func (*DB) AcquireValues ¶
func (*DB) Delete ¶
func (db *DB) Delete(ctx context.Context, table Identifier, cond QueryEncoder) (count int64, err error)
func (*DB) Exec ¶
Exec executes sql. sql can be either a prepared statement name or an SQL string. arguments should be referenced positionally from the sql string as $1, $2, etc.
func (*DB) InsertValues ¶
func (*DB) Query ¶
Query sends a query to the server and returns a Rows to read the results. Only errors encountered sending the query and initializing Rows will be returned. Err() on the returned Rows must be checked after the Rows is closed to determine if the query executed successfully.
The returned Rows must be closed before the connection can be used again. It is safe to attempt to read from the returned Rows even if an error is returned. The error will be the available in rows.Err() after rows are closed. It is allowed to ignore the error returned from Query and handle it in Rows.
It is possible for a call of FieldDescriptions on the returned Rows to return nil even if the Query call did not return an error.
It is possible for a query to return one or more rows before encountering an error. In most cases the rows should be collected before processing rather than processed while receiving each row. This avoids the possibility of the application processing rows from a query that the server rejected. The CollectRows function is useful here.
func (*DB) QueryRow ¶
QueryRow is a convenience wrapper over Query. Any error that occurs while querying is deferred until calling Scan on the returned Row. That Row will error with ErrNoRows if no rows are returned.
func (*DB) ReleaseValues ¶
func (*DB) Transaction ¶
func (*DB) UpdateValues ¶
func (db *DB) UpdateValues(ctx context.Context, table Identifier, vals *Values, cond QueryEncoder) (count int64, err error)
type Identifier ¶
type Identifier string
func (Identifier) EncodeString ¶
func (t Identifier) EncodeString(b *fast.StringBuffer)
EncodeString implements fast.StringEncoder.
type MultiAnd ¶
type MultiAnd interface { QueryEncoder And(QueryEncoder) MultiAnd }
func And ¶
func And(ops ...QueryEncoder) MultiAnd
type MultiOr ¶
type MultiOr interface { QueryEncoder Or(QueryEncoder) MultiOr }
func Or ¶
func Or(ops ...QueryEncoder) MultiOr
type QueryEncoder ¶
type QueryEncoder interface {
EncodeQuery(buf *fast.StringBuffer, queryArgs *[]any)
}
func Eq ¶
func Eq(col string, val any) QueryEncoder
func Gt ¶
func Gt(col string, val any) QueryEncoder
func Gte ¶
func Gte(col string, val any) QueryEncoder
func In ¶
func In(col string, val any) QueryEncoder
func Lt ¶
func Lt(col string, val any) QueryEncoder
func Lte ¶
func Lte(col string, val any) QueryEncoder
func NotEq ¶
func NotEq(col string, val any) QueryEncoder
func NotIn ¶
func NotIn(col string, val any) QueryEncoder
func Raw ¶
func Raw(s string, args ...any) QueryEncoder
func Search ¶ added in v0.1.0
func Search(col, val string, options ...SearchOptions) QueryEncoder