sqldb

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2019 License: LGPL-3.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NullDateTime = "1000-01-01 00:00:00"
)

Variables

View Source
var (
	NullTime, _ = time.Parse("2006-01-02 15:04:05", NullDateTime)

	ErrInvalidPage  = errors.New("invalid page")
	ErrInvalidLimit = errors.New("invalid limit")
)

Functions

func Hex

func Hex(data []byte) string

func InClauseForBytes

func InClauseForBytes(arr [][]byte) string

func New

func New(driver string, opts ...database.Option) (db *sqlx.DB, err error)

New creates a sql.DB object with connectivity.

func NewTx

func NewTx(ctx context.Context, dbOrTx DbOrTx) (*sqlx.Tx, func(*error), error)

NewTx news a db transaction from db instance or returns the existing one

func SimpleConnect

func SimpleConnect(driver, connectionString string) (sqlDB *sqlx.DB, err error)

func ToTimeStr

func ToTimeStr(now time.Time) string

Types

type DbOrTx

type DbOrTx interface {
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

DbOrTx defines the minimal set of sqlx database we use. Used when a database store needs either a database or a DB transaction.

type QueryParameters

type QueryParameters struct {
	Page  uint64
	Limit uint64
}

Jump to

Keyboard shortcuts

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