aqua

package module
v0.0.0-...-556df78 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2017 License: MIT Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProvider

func RegisterProvider(provider string, h OpenHandler)

Types

type Config

type Config struct {
	Host     string `yaml:"host" json:"host"`
	Port     string `yaml:"port" json:"port"`
	Socket   string `yaml:"socket" json:"socket"`
	UserName string `yaml:"username" json:"username"`
	Password string `yaml:"password" json:"password"`
	Database string `yaml:"database" json:"database"`
	TLS      bool   `yaml:"tls" json:"tls"`
}

func (*Config) DSN

func (c *Config) DSN(driver string) string

type DB

type DB interface {
	Begin(ctx context.Context, opts *sql.TxOptions) (Tx, error)
	Close() error
	Driver() driver.Driver
	Ping(ctx context.Context) error
	SetMaxIdleConns(n int)
	SetMaxOpenConns(n int)

	QueryRunner

	// for customize original provider
	GetProvider() interface{}
}

func Open

func Open(provider, driver, path string) (DB, error)

type OpenHandler

type OpenHandler func(string, string) (DB, error)

type QueryRunner

type QueryRunner interface {
	Table(name string) StmtTable
	Exec(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

type Row

type Row interface {
	ScanRow(dest interface{}) error
	Scan(dest ...interface{}) error
}

type Rows

type Rows interface {
	Close() error
	Columns() ([]string, error)
	Err() error
	Next() bool

	Scan(dest ...interface{}) error // sql.Rows 's Scan()
	ScanAll(dest interface{}) error
}

type StmtAggregate

type StmtAggregate interface {
	StmtRunner

	// こいつらは2回呼ぶと上書き、もしくはpanicさせたほうがいいか
	GroupBy(columns ...string) StmtAggregate
	OrderBy(columns ...string) StmtAggregate
	Having(condition string) StmtAggregate
	LimitOffset(limit, offset int) StmtAggregate
}

type StmtCondition

type StmtCondition interface {
	StmtAggregate

	// Where系は検討の余地がたくさんあって悩んでいる
	Where(condition string, bind ...interface{}) StmtCondition
	WhereEq(column string, value interface{}) StmtCondition
	WhereIn(column string, values ...interface{}) StmtCondition
	WhereBetween(column string, a, b interface{}) StmtCondition
	WhereLike(column, pattern string) StmtCondition
}

type StmtRunner

type StmtRunner interface {
	All(ctx context.Context) (Rows, error)
	Single(ctx context.Context) (Row, error)
	FetchColumn(ctx context.Context, column string) (Rows, error)
	Count(ctx context.Context) (int, error)

	Update(ctx context.Context, v interface{}) error
	Delete(ctx context.Context, v interface{}) error
}

type StmtTable

type StmtTable interface {
	StmtCondition
	Join(table, condition string) StmtTable
	LeftJoin(table, condition string) StmtTable
	RightJoin(table, condition string) StmtTable
	Select(columns ...string) StmtTable

	Create(ctx context.Context, values ...interface{}) error
}

type TestSuite

type TestSuite struct {
	*testing.T
	// contains filtered or unexported fields
}

func NewTestSuite

func NewTestSuite(t *testing.T, provider string) *TestSuite

func (*TestSuite) Run

func (t *TestSuite) Run()

type Tx

type Tx interface {
	Commit() error
	Rollback() error

	QueryRunner
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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