sqlx-transactionmanager: github.com/Code-Hex/sqlx-transactionmanager Index | Files | Directories

package sqlx

import "github.com/Code-Hex/sqlx-transactionmanager"


Package Files

transaction_error.go transaction_manager.go

func In Uses

func In(query string, args ...interface{}) (string, []interface{}, error)

In expands slice values in args, returning the modified query string and a new arg list that can be executed by a database. The `query` should use the `?` bindVar. The return value uses the `?` bindVar.

type DB Uses

type DB struct {
    // contains filtered or unexported fields

DB is a wrapper around *github.com/jmoiron/sqlx.DB which manages transaction.

func MustOpen Uses

func MustOpen(driverName, dataSourceName string) *DB

MustOpen returns only pointer of DB struct to manage transaction. But If you cause something error, It will do panic.

func Open Uses

func Open(driverName, dataSourceName string) (*DB, error)

Open returns pointer of DB struct to manage transaction. It struct wrapped *github.com/jmoiron/sqlx.DB So we can use some methods of *github.com/jmoiron/sqlx.DB.

func (*DB) BeginTxm Uses

func (db *DB) BeginTxm() (*Txm, error)

BeginTxm begins a transaction and returns pointer of transaction manager. Actually, This method will invoke *github.com/jmoiron/sqlx.Beginx(). but returns error if failed it.

func (*DB) BeginTxmx Uses

func (db *DB) BeginTxmx(ctx context.Context, opts *sql.TxOptions) (*Txm, error)

BeginTxmx begins a transaction and returns pointer of transaction manager.

The provided context is used until the transaction is committed or rolled back. If the context is canceled, the sql package will roll back the transaction. Tx.Commit will return an error if the context provided to BeginxContext is canceled.

func (*DB) Close Uses

func (db *DB) Close() error

Close closes *github.com/jmoiron/sqlx.DB

func (*DB) MustBeginTxm Uses

func (db *DB) MustBeginTxm() *Txm

MustBeginTxm is like BeginTxm but panics if BeginTxm cannot begin transaction.

func (*DB) MustBeginTxmx Uses

func (db *DB) MustBeginTxmx(ctx context.Context, opts *sql.TxOptions) (*Txm, error)

MustBeginTxmx is like BeginTxmx but panics if BeginTxmx cannot begin transaction.

func (*DB) SQL Uses

func (db *DB) SQL() *sql.DB

SQL returns *sql.DB The reason for writing this method is that it needs to be written as *db.DB.DB to access *sql.DB.

type NestedCommitErr Uses

type NestedCommitErr struct{}

NestedCommitErr is an error type to notice that commit in nested transaction.

func (*NestedCommitErr) Error Uses

func (n *NestedCommitErr) Error() string

type Txm Uses

type Txm struct {
    // contains filtered or unexported fields

Txm is a wrapper around *github.com/jmoiron/sqlx.DB with extra functionality and manages transaction.

func (*Txm) Commit Uses

func (t *Txm) Commit() error

Commit commits the transaction.

func (*Txm) Rollback Uses

func (t *Txm) Rollback() error

Rollback rollbacks the transaction.



Package sqlx imports 4 packages (graph) and is imported by 2 packages. Updated 2018-11-15. Refresh now. Tools for package owners.