dbc

package
v0.0.0-...-5bf8bb3 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AfterCallback

type AfterCallback func(ctx context.Context, query string, took time.Duration, err error)

AfterCallback is a kind of function that can be called after a query was executed.

type BeforeCallback

type BeforeCallback func(ctx context.Context, query string)

BeforeCallback is a kind of function that can be called before a query is executed.

type Conn

type Conn interface {

	// Begin executes a transaction.
	Begin(context.Context, func(Tx) error) error
	// BeginCustom executes a transaction with provided options.
	BeginCustom(context.Context, func(Tx) error, *sql.TxOptions) error
	// Close closes the connection.
	Close() error
	// DB returns the underlying DB object.
	DB() *sql.DB
	// Before adds a callback function that would be called before a query is
	// executed.
	Before(BeforeCallback)
	// After adds a callback function that would be called after a query was
	// executed.
	After(AfterCallback)
	// contains filtered or unexported methods
}

Conn represents database connection.

func Connect

func Connect(ctx context.Context, f Flavor, dsn string) (Conn, error)

Connect establishes a new database connection.

type ExecChain

type ExecChain interface {
	// contains filtered or unexported methods
}

ExecChain ...

type ExecResult

type ExecResult interface {
	Error() error
	LastInsertID() int64
	RowsAffected() int64
	Result() sql.Result
	Then() ExecChain
}

ExecResult ...

type Flavor

type Flavor string

Flavor defines a kind of SQL database.

const (
	// MySQL is the MySQL SQL flavor.
	MySQL Flavor = "mysql"
	// PostgreSQL is the PostgreSQL SQL flavor.
	PostgreSQL Flavor = "postgresql"
)

type Rows

type Rows interface {
	Error() error
	Load(dest interface{}) error
	Rows() *sql.Rows
}

Rows ...

type Tx

type Tx interface {
	Commit() error
	Rollback() error
	// contains filtered or unexported methods
}

Tx represents database transacation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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