wrapper

package
v0.0.0-...-76fb0fb Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// RawQueryOption is the raw query option.
	// rawQueryOption convert the '?' place to real data.
	// Ex: "SELECT a FROM b WHERE c = ?" will be "SELECT a FROM b WHERE c = d ".
	RawQueryOption = rawQueryOption{}
	// IgnoreSelectColumnsOption enable the ignore select columns option,
	// Ex: "SELECT A,B FROM C WHERE D = ?" will be "SELECT ... FROM C WHERE D = ?".
	IgnoreSelectColumnsOption = ignoreSelectColumnsOption{}
)

Functions

This section is empty.

Types

type ExecContextFunc

type ExecContextFunc func(ctx context.Context, sql string, args ...interface{}) (sql.Result, error)

define the exec func with context.

type QueryContextFunc

type QueryContextFunc func(ctx context.Context, sql string, args ...interface{}) (*sql.Rows, error)

define the query func with context.

type TracerOption

type TracerOption interface {
	QueryBuilder() func(query string, args ...interface{}) string
}

TracerOption define the wrapper's option

type TracerWrapper

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

func NewMsSQLTracerWrapper

func NewMsSQLTracerWrapper() *TracerWrapper

Init TracerWrapper with default ignoreSelectColumnsOption.

func NewMsSQLTracerWrapperWithOpts

func NewMsSQLTracerWrapperWithOpts(options ...TracerOption) *TracerWrapper

Init pure TracerWrapper with set options.

func NewMySQLTracerWrapper

func NewMySQLTracerWrapper() *TracerWrapper

Init TracerWrapper with default ignoreSelectColumnsOption.

func NewMySQLTracerWrapperWithOpts

func NewMySQLTracerWrapperWithOpts(options ...TracerOption) *TracerWrapper

Init pure TracerWrapper with set options.

func NewTracerWrapper

func NewTracerWrapper(dbType string) *TracerWrapper

func (*TracerWrapper) QueryBuilder

func (t *TracerWrapper) QueryBuilder(query string, args ...interface{}) string

func (*TracerWrapper) WrapExecContext

func (t *TracerWrapper) WrapExecContext(fn ExecContextFunc) ExecContextFunc

For sql's update、insert、delete ...

func (*TracerWrapper) WrapQueryContext

func (t *TracerWrapper) WrapQueryContext(fn QueryContextFunc) QueryContextFunc

For sql's select ...

type Wrapper

type Wrapper interface {
	WrapQueryContext(fn QueryContextFunc) QueryContextFunc
	WrapExecContext(fn ExecContextFunc) ExecContextFunc
}

define the database operation.

Jump to

Keyboard shortcuts

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