db

package
v0.0.0-...-fc8bcac Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2019 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPrefix

func AddPrefix(fields []string, prefix string) []string

AddPrefix add prefix to all items

func Assign

func Assign(field string, value string) string

Assign create assign operation

func Equal

func Equal(field string, value string) string

Equal create equal operation

func Extract

func Extract(fields []string, prefix string) string

Extract convert array of fields into string of fields

func NewContext

func NewContext(ctx context.Context, q Queryable) context.Context

NewContext ...

func RunAlwaysRollbackTransaction

func RunAlwaysRollbackTransaction(db *sqlx.DB, f func(tx *sqlx.Tx) error) error

RunAlwaysRollbackTransaction runs function with the transaction context without applying the context and rollback

func RunInTransaction

func RunInTransaction(db *sqlx.DB, obj IRunInTransaction, f func(tx *sqlx.Tx) error) error

RunInTransaction runs function with transaction context and auto apply the context into existing IRunTransaction object

func RunInTransactionWithDB

func RunInTransactionWithDB(db *sqlx.DB, f func(tx *sqlx.Tx) error) error

RunInTransactionWithDB runs function with the transaction context without applying the context

Types

type Entity

type Entity interface {
	IsEmpty() bool
	IsEqual(b interface{}) bool
}

Entity basic behavior for model

type IRunInTransaction

type IRunInTransaction interface {
	UpdateQueryable(queryable QueryableContext)
}

IRunInTransaction interface for calling runInTransactionWith

type Order

type Order struct {
	By        string
	Direction string
}

Order model for order by clause

type Queryable

type Queryable interface {
	BindNamed(query string, arg interface{}) (string, []interface{}, error)
	DriverName() string
	Get(dest interface{}, query string, args ...interface{}) error
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	MustExec(query string, args ...interface{}) sql.Result
	MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result
	NamedExec(query string, arg interface{}) (sql.Result, error)
	NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)
	NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)
	PrepareNamed(query string) (*sqlx.NamedStmt, error)
	PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)
	Preparex(query string) (*sqlx.Stmt, error)
	PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)
	QueryRowx(query string, args ...interface{}) *sqlx.Row
	QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row
	Queryx(query string, args ...interface{}) (*sqlx.Rows, error)
	QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)
	Rebind(query string) string
	Select(dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
}

Queryable ...

func QueryableFromContext

func QueryableFromContext(ctx context.Context) (Queryable, bool)

QueryableFromContext ...

type QueryableContext

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

QueryableContext ...

func NewQueryableContext

func NewQueryableContext(db *sqlx.DB) QueryableContext

NewQueryableContext ...

func NewQueryableContextFromTx

func NewQueryableContextFromTx(tx *sqlx.Tx) QueryableContext

NewQueryableContextFromTx ...

func (*QueryableContext) BindNamed

func (qtx *QueryableContext) BindNamed(query string, arg interface{}) (string, []interface{}, error)

BindNamed ...

func (*QueryableContext) DB

func (qtx *QueryableContext) DB() *sqlx.DB

DB return db

func (*QueryableContext) DriverName

func (qtx *QueryableContext) DriverName() string

DriverName ...

func (*QueryableContext) Get

func (qtx *QueryableContext) Get(dest interface{}, query string, args ...interface{}) error

Get ...

func (*QueryableContext) GetContext

func (qtx *QueryableContext) GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

GetContext ...

func (*QueryableContext) MustExec

func (qtx *QueryableContext) MustExec(query string, args ...interface{}) sql.Result

MustExec ...

func (*QueryableContext) MustExecContext

func (qtx *QueryableContext) MustExecContext(ctx context.Context, query string, args ...interface{}) sql.Result

MustExecContext ...

func (*QueryableContext) NamedExec

func (qtx *QueryableContext) NamedExec(query string, arg interface{}) (sql.Result, error)

NamedExec ...

func (*QueryableContext) NamedExecContext

func (qtx *QueryableContext) NamedExecContext(ctx context.Context, query string, arg interface{}) (sql.Result, error)

NamedExecContext ...

func (*QueryableContext) NamedQuery

func (qtx *QueryableContext) NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)

NamedQuery ...

func (*QueryableContext) PrepareNamed

func (qtx *QueryableContext) PrepareNamed(query string) (*sqlx.NamedStmt, error)

PrepareNamed ...

func (*QueryableContext) PrepareNamedContext

func (qtx *QueryableContext) PrepareNamedContext(ctx context.Context, query string) (*sqlx.NamedStmt, error)

PrepareNamedContext ...

func (*QueryableContext) Preparex

func (qtx *QueryableContext) Preparex(query string) (*sqlx.Stmt, error)

Preparex ...

func (*QueryableContext) PreparexContext

func (qtx *QueryableContext) PreparexContext(ctx context.Context, query string) (*sqlx.Stmt, error)

PreparexContext ...

func (*QueryableContext) QueryRowx

func (qtx *QueryableContext) QueryRowx(query string, args ...interface{}) *sqlx.Row

QueryRowx ...

func (*QueryableContext) QueryRowxContext

func (qtx *QueryableContext) QueryRowxContext(ctx context.Context, query string, args ...interface{}) *sqlx.Row

QueryRowxContext ...

func (*QueryableContext) Queryx

func (qtx *QueryableContext) Queryx(query string, args ...interface{}) (*sqlx.Rows, error)

Queryx ...

func (*QueryableContext) QueryxContext

func (qtx *QueryableContext) QueryxContext(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error)

QueryxContext ...

func (*QueryableContext) Rebind

func (qtx *QueryableContext) Rebind(query string) string

Rebind ...

func (*QueryableContext) Select

func (qtx *QueryableContext) Select(dest interface{}, query string, args ...interface{}) error

Select ...

func (*QueryableContext) SelectContext

func (qtx *QueryableContext) SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error

SelectContext ...

func (*QueryableContext) Tx

func (qtx *QueryableContext) Tx() *sqlx.Tx

Tx return tx

type Scanner

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

Scanner helper for combinining sql.row and sql.rows

Jump to

Keyboard shortcuts

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