sqlxtpl

package
v0.0.0-...-f70f7d2 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Begin

func Begin(db *sqlx.DB) (*sqlx.Tx, error)

Begin creates a sqlx transaction

func Commit

func Commit(tx *sqlx.Tx) error

Commit applies queries of the transaction

func IsEmptyResultDataError

func IsEmptyResultDataError(err error) bool

IsEmptyResultDataError verifies if error is an EmptyResultDataError

func NewEmptyResultDataError

func NewEmptyResultDataError(err error) error

NewEmptyResultDataError creates an EmptyResultDataError instance

func NullInt

func NullInt(i int) null.Int

NullInt returns a invalid null.Int when i is zero

func Rollback

func Rollback(tx *sqlx.Tx) error

Rollback undoes queries of the transaction

Types

type EmptyResultDataError

type EmptyResultDataError struct {
	errors.BaseError
}

EmptyResultDataError error type for an empty result database

type ParseRows

type ParseRows func(r *sqlx.Rows) error

ParseRows is used as a callback function to parse query result

type SqlxTpl

type SqlxTpl struct {
	TransactedSQL

	DB *sqlx.DB
}

SqlxTpl is a template for database queries

func NewSqlxTpl

func NewSqlxTpl(db *sqlx.DB) SqlxTpl

NewSqlxTpl creates a SqlxTpl instance

func (SqlxTpl) Get

func (s SqlxTpl) Get(dest interface{}, query string, args ...interface{}) error

Get executes safe get on the database connection

func (SqlxTpl) NamedExec

func (s SqlxTpl) NamedExec(query string, arg interface{}) (result sql.Result, err error)

NamedExec executes a namedexec query If a transaction is setted, the query runs over it

func (SqlxTpl) NamedQuery

func (s SqlxTpl) NamedQuery(query string, arg interface{}, parse ParseRows) error

NamedQuery executes a safe named query

func (SqlxTpl) Queryx

func (s SqlxTpl) Queryx(query string, args []interface{}, parse ParseRows) error

Queryx executes a safe query

func (SqlxTpl) Select

func (s SqlxTpl) Select(dest interface{}, query string, args ...interface{}) error

Select executes a safe select

func (*SqlxTpl) TxDo

func (s *SqlxTpl) TxDo(do func(tx *sqlx.Tx) error) error

TxDo executes a callback function with a shared transaction

func (SqlxTpl) TxNamedExec

func (s SqlxTpl) TxNamedExec(tx *sqlx.Tx, query string, arg interface{}) (sql.Result, error)

TxNamedExec executes the query with a transaction

func (SqlxTpl) UnsafeGet

func (s SqlxTpl) UnsafeGet(dest interface{}, query string, args ...interface{}) error

UnsafeGet executes unsafe get on the database connection

func (SqlxTpl) UnsafeNamedQuery

func (s SqlxTpl) UnsafeNamedQuery(query string, arg interface{}, parse ParseRows) error

UnsafeNamedQuery executes an unsafe named query

func (SqlxTpl) UnsafeQueryx

func (s SqlxTpl) UnsafeQueryx(query string, parse ParseRows, args ...interface{}) error

UnsafeQueryx executes an unsafe query

func (SqlxTpl) UnsafeSelect

func (s SqlxTpl) UnsafeSelect(dest interface{}, query string, args ...interface{}) error

UnsafeSelect executes an unsafe select

type TransactedSQL

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

TransactedSQL should be embedded on sql repositories

func (*TransactedSQL) SetTx

func (t *TransactedSQL) SetTx(tx *sqlx.Tx)

SetTx sets the sql transaction

func (*TransactedSQL) Tx

func (t *TransactedSQL) Tx() *sqlx.Tx

Tx gets the sql transaction

type TxSQLSetter

type TxSQLSetter interface {
	SetTx(tx *sqlx.Tx)
}

TxSQLSetter interface for a struct that supports transaction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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