migrator

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

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

Go to latest
Published: Sep 8, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(driver, databaseName string) (db *database, err error)

Open a database, similar to sql.Open

Types

type Cursor

type Cursor interface {
	Next() bool
	Scan(dest ...interface{}) error
	GetMap() (map[string]interface{}, error)
	Close() error
}

type Database

type Database interface {
	// GetDB Get the underlying sql.DB object of the database
	GetDB() *sql.DB

	// Query Executes a query and return the cursor
	Query(sql string) (Cursor, error)
	// QueryContext Executes a query with context and return the cursor
	QueryContext(ctx context.Context, sqlString string) (Cursor, error)
	// Execute Executes a statement
	Execute(sql string) (sql.Result, error)
	// ExecuteContext Executes a statement with context
	ExecuteContext(ctx context.Context, sql string) (sql.Result, error)
	// SetLogger Set the logger function
	SetLogger(logger func(sql string, durationNano int64))
	// SetRetryPolicy Set the retry policy function.
	// The retry policy function returns true if needs retry.
	SetRetryPolicy(retryPolicy func(err error) bool)
	// EnableCallerInfo enable or disable caller info
	EnableCallerInfo(enableCallerInfo bool)
	// SetInterceptor Set a interceptor function
	SetInterceptor(interceptor InterceptorFunc)
}

Database is the interface of a database with underlying sql.DB object.

type InterceptorFunc

type InterceptorFunc = func(ctx context.Context, sql string, invoker InvokerFunc) error

InterceptorFunc is the function type of an interceptor. An interceptor should implement this function to fulfill it's purpose.

type InvokerFunc

type InvokerFunc = func(ctx context.Context, sql string) error

InvokerFunc is the function type of the actual invoker. It should be called in an interceptor.

type Table

type Table interface {
}

Jump to

Keyboard shortcuts

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