Documentation ¶
Index ¶
- Variables
- type ConnectionOptions
- type Handle
- type HookHandle
- func (h *HookHandle) ReadOnly(ctx context.Context, do func(ctx context.Context) error) (err error)
- func (h *HookHandle) UseHook(ctx context.Context, hook TransactionHook)
- func (h *HookHandle) WithPrepareStatementsHandle(ctx context.Context, ...) (err error)
- func (h *HookHandle) WithTx(ctx context.Context, do func(ctx context.Context) error) (err error)
- type InsertBuilder
- type MockHandle
- type PQListener
- type PageKey
- type Pool
- type PreparedStatementsHandle
- type SQLBuilder
- type SQLBuilderApp
- type SQLExecutor
- type Scanner
- type SelectBuilder
- func (b SelectBuilder) From(from string, alias ...string) SelectBuilder
- func (b SelectBuilder) Join(from string, alias string, pred string, args ...interface{}) SelectBuilder
- func (b SelectBuilder) LeftJoin(from string, alias string, pred string, args ...interface{}) SelectBuilder
- func (b SelectBuilder) Limit(limit uint64) SelectBuilder
- func (b SelectBuilder) Offset(offset uint64) SelectBuilder
- func (b SelectBuilder) OrderBy(orderBy ...string) SelectBuilder
- func (b SelectBuilder) PrefixExpr(expr sq.Sqlizer) SelectBuilder
- func (b SelectBuilder) ToSql() (string, []interface{}, error)
- func (b SelectBuilder) Where(pred interface{}, args ...interface{}) SelectBuilder
- type TransactionHook
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrInvalidCursor = InvalidCursor.New("invalid pagination cursor")
View Source
var ErrWriteConflict = apierrors.NewDataRace("concurrent write conflict occurred")
View Source
var InvalidCursor = apierrors.Invalid.WithReason("InvalidCursor")
View Source
var InvalidQuery = apierrors.BadRequest.WithReason("InvalidQuery")
Functions ¶
This section is empty.
Types ¶
type ConnectionOptions ¶
type Handle ¶
type Handle interface { // WithTx runs do within a transaction. // If there is no error, the transaction is committed. WithTx(ctx context.Context, do func(ctx context.Context) error) (err error) // ReadOnly runs do within a transaction. // The transaction is always rolled back. ReadOnly(ctx context.Context, do func(ctx context.Context) error) (err error) }
Handle allows a function to be run within a transaction.
type HookHandle ¶
type HookHandle struct { Pool *Pool ConnectionOptions ConnectionOptions Logger *log.Logger }
func NewHookHandle ¶
func NewHookHandle(pool *Pool, opts ConnectionOptions, lf *log.Factory) *HookHandle
func (*HookHandle) UseHook ¶
func (h *HookHandle) UseHook(ctx context.Context, hook TransactionHook)
func (*HookHandle) WithPrepareStatementsHandle ¶
func (h *HookHandle) WithPrepareStatementsHandle(ctx context.Context, do func(ctx context.Context, handle PreparedStatementsHandle) error) (err error)
func (*HookHandle) WithTx ¶
WithTx commits if do finishes without error and rolls back otherwise. WithTx is reentrant, meaning that you can call WithTx even when a previous WithTx does not finish yet. Normally you should not call WithTx within a WithTx, but there is a legit use case.
// Assume ctx is a http.Request context. h.WithTx(ctx, func(ctx context.Context) error { // ctx here is associated with a *sql.Tx (Tx1) go func() { // ctx is detached from the http.Request context. ctx = ctx.WithCancel(ctx) h.WithTx(ctx, func(ctx context.Context) error { // ctx is associated with a *sqlTx (Tx2) }) }() })
type InsertBuilder ¶
type InsertBuilder struct {
// contains filtered or unexported fields
}
func (InsertBuilder) Columns ¶
func (b InsertBuilder) Columns(columns ...string) InsertBuilder
func (InsertBuilder) Suffix ¶
func (b InsertBuilder) Suffix(sql string, args ...interface{}) InsertBuilder
func (InsertBuilder) ToSql ¶
func (b InsertBuilder) ToSql() (string, []interface{}, error)
nolint: golint
func (InsertBuilder) Values ¶
func (b InsertBuilder) Values(values ...interface{}) InsertBuilder
type PQListener ¶
type PageKey ¶
type PageKey struct {
Offset uint64
}
func NewFromPageCursor ¶
func NewFromPageCursor(k model.PageCursor) (*PageKey, error)
func (*PageKey) ToPageCursor ¶
func (k *PageKey) ToPageCursor() (model.PageCursor, error)
type PreparedStatementsHandle ¶
type PreparedStatementsHandle interface { // WithTx runs do within a transaction. // If there is no error, the transaction is committed. WithTx(ctx context.Context, do func(ctx context.Context) error) (err error) }
PreparedStatementsHandle prepares and caches query.
type SQLBuilder ¶
type SQLBuilder struct { sq.StatementBuilderType // contains filtered or unexported fields }
func NewSQLBuilder ¶
func NewSQLBuilder(schema string) SQLBuilder
type SQLBuilderApp ¶
type SQLBuilderApp struct {
// contains filtered or unexported fields
}
func NewSQLBuilderApp ¶
func NewSQLBuilderApp(schema string, appID string) SQLBuilderApp
func (SQLBuilderApp) Delete ¶
func (b SQLBuilderApp) Delete(from string) sq.DeleteBuilder
func (SQLBuilderApp) Insert ¶
func (b SQLBuilderApp) Insert(into string) InsertBuilder
func (SQLBuilderApp) Select ¶
func (b SQLBuilderApp) Select(columns ...string) SelectBuilder
func (SQLBuilderApp) Update ¶
func (b SQLBuilderApp) Update(table string) sq.UpdateBuilder
type SQLExecutor ¶
type SQLExecutor struct{}
func (*SQLExecutor) QueryRowWith ¶
type Scanner ¶
type Scanner interface {
Scan(dest ...interface{}) error
}
Scanner is *sql.Row or *sql.Rows.
type SelectBuilder ¶
type SelectBuilder struct {
// contains filtered or unexported fields
}
func ApplyPageArgs ¶
func ApplyPageArgs(builder SelectBuilder, pageArgs graphqlutil.PageArgs) (out SelectBuilder, offset uint64, err error)
func (SelectBuilder) From ¶
func (b SelectBuilder) From(from string, alias ...string) SelectBuilder
func (SelectBuilder) Join ¶
func (b SelectBuilder) Join(from string, alias string, pred string, args ...interface{}) SelectBuilder
func (SelectBuilder) LeftJoin ¶
func (b SelectBuilder) LeftJoin(from string, alias string, pred string, args ...interface{}) SelectBuilder
func (SelectBuilder) Limit ¶
func (b SelectBuilder) Limit(limit uint64) SelectBuilder
func (SelectBuilder) Offset ¶
func (b SelectBuilder) Offset(offset uint64) SelectBuilder
func (SelectBuilder) OrderBy ¶
func (b SelectBuilder) OrderBy(orderBy ...string) SelectBuilder
func (SelectBuilder) PrefixExpr ¶
func (b SelectBuilder) PrefixExpr(expr sq.Sqlizer) SelectBuilder
func (SelectBuilder) ToSql ¶
func (b SelectBuilder) ToSql() (string, []interface{}, error)
nolint: golint
func (SelectBuilder) Where ¶
func (b SelectBuilder) Where(pred interface{}, args ...interface{}) SelectBuilder
Source Files ¶
Click to show internal directories.
Click to hide internal directories.