db

package
v0.0.0-...-04ccfb0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

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 ConnectionOptions struct {
	DatabaseURL           string
	MaxOpenConnection     int
	MaxIdleConnection     int
	MaxConnectionLifetime time.Duration
	IdleConnectionTimeout time.Duration
}

type Handle

type Handle interface {
	// WithTx runs do within a transaction.
	// If there is no error, the transaction is committed.
	WithTx(do func() error) (err error)

	// ReadOnly runs do within a transaction.
	// The transaction is always rolled back.
	ReadOnly(do func() error) (err error)
	// contains filtered or unexported methods
}

Handle allows a function to be run within a transaction.

type HookHandle

type HookHandle struct {
	Context           context.Context
	Pool              *Pool
	ConnectionOptions ConnectionOptions
	Logger            *log.Logger
	// contains filtered or unexported fields
}

func NewHookHandle

func NewHookHandle(ctx context.Context, pool *Pool, opts ConnectionOptions, lf *log.Factory) *HookHandle

func (*HookHandle) ReadOnly

func (h *HookHandle) ReadOnly(do func() error) (err error)

ReadOnly runs do in a transaction and rolls back always.

func (*HookHandle) UseHook

func (h *HookHandle) UseHook(hook TransactionHook)

func (*HookHandle) WithTx

func (h *HookHandle) WithTx(do func() error) (err error)

WithTx commits if do finishes without error and rolls back otherwise.

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 MockHandle

type MockHandle struct{}

func (*MockHandle) ReadOnly

func (h *MockHandle) ReadOnly(do func() error) (err error)

func (*MockHandle) WithTx

func (h *MockHandle) WithTx(do func() error) (err error)

type PQListener

type PQListener struct {
	DatabaseURL string
	Listener    *pq.Listener
}

func (*PQListener) Listen

func (p *PQListener) Listen(channels []string, done <-chan struct{}, onChange func(channel string, extra string), onError func(error))

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 Pool

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

func NewPool

func NewPool() *Pool

func (*Pool) Close

func (p *Pool) Close() (err error)

func (*Pool) Open

func (p *Pool) Open(opts ConnectionOptions) (db *sqlx.DB, err error)

type SQLBuilder

type SQLBuilder struct {
	sq.StatementBuilderType
	// contains filtered or unexported fields
}

func NewSQLBuilder

func NewSQLBuilder(schema string) SQLBuilder

func (SQLBuilder) TableName

func (b SQLBuilder) TableName(table string) string

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) TableName

func (b SQLBuilderApp) TableName(table string) string

func (SQLBuilderApp) Update

func (b SQLBuilderApp) Update(table string) sq.UpdateBuilder

type SQLExecutor

type SQLExecutor struct {
	Context  context.Context
	Database Handle
}

func (*SQLExecutor) ExecWith

func (e *SQLExecutor) ExecWith(sqlizeri sq.Sqlizer) (sql.Result, error)

func (*SQLExecutor) QueryRowWith

func (e *SQLExecutor) QueryRowWith(sqlizeri sq.Sqlizer) (*sqlx.Row, error)

func (*SQLExecutor) QueryWith

func (e *SQLExecutor) QueryWith(sqlizeri sq.Sqlizer) (*sqlx.Rows, error)

type Scanner

type Scanner interface {
	Scan(dest ...interface{}) error
}

Scanner is sqlx.Row or sqlx.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) 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

type TransactionHook

type TransactionHook interface {
	WillCommitTx() error
	DidCommitTx()
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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