rdb

package
v0.0.48 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err int
const (
	UnknownErrCode Err = iota
	IllegalParams
)

func (Err) String

func (i Err) String() string

type Instruct

type Instruct struct {
	Sql  string
	Args []interface{}
}

type InstructOptionFunc added in v0.0.46

type InstructOptionFunc func(*instructOpts)

func WithPlaceholder

func WithPlaceholder(placeholder string) InstructOptionFunc

type Meta added in v0.0.46

type Meta struct {
	IP       string
	Port     string
	DbName   string
	UserName string
	PassWord string

	MaxIdleConns int
	MaxLifeTime  time.Duration

	Logger log.API
}

type MetaOptionFunc added in v0.0.46

type MetaOptionFunc func(*Meta)

func WithDbName

func WithDbName(dbName string) MetaOptionFunc

func WithIp

func WithIp(ip string) MetaOptionFunc

func WithLogger

func WithLogger(logger log.API) MetaOptionFunc

func WithMaxIdleConns

func WithMaxIdleConns(MaxIdleConns int) MetaOptionFunc

func WithMaxLifeTime

func WithMaxLifeTime(MaxLifeTime time.Duration) MetaOptionFunc

func WithPassWord

func WithPassWord(PassWord string) MetaOptionFunc

func WithPort

func WithPort(port string) MetaOptionFunc

func WithUserName

func WithUserName(UserName string) MetaOptionFunc

type QueryOption

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

type QueryOptionFunc

type QueryOptionFunc func(*SqlOption)

func WithColumn

func WithColumn(column []string) QueryOptionFunc

func WithWhere

func WithWhere(where map[string]interface{}) QueryOptionFunc

type Rdb

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

func NewRdb

func NewRdb(dbType Type, opts ...MetaOptionFunc) (*Rdb, error)

func (*Rdb) Delete

func (r *Rdb) Delete(ctx context.Context, table string, where map[string]interface{}, opts ...QueryOptionFunc) (map[string]int64, error)

func (*Rdb) Engine added in v0.0.46

func (r *Rdb) Engine() *sqlx.DB

func (*Rdb) Insert

func (r *Rdb) Insert(ctx context.Context, table string, data map[string]interface{}, opts ...QueryOptionFunc) (map[string]int64, error)

func (*Rdb) Query

func (r *Rdb) Query(ctx context.Context, table []string, opts ...QueryOptionFunc) ([]map[string]interface{}, error)

func (*Rdb) Update

func (r *Rdb) Update(ctx context.Context, table string, data map[string]interface{}, where map[string]interface{}, opts ...QueryOptionFunc) (map[string]int64, error)

type SqlOption

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

type Type

type Type int64
const (
	UnknownType Type = iota
	Mysql
	Sqlite
)

func (Type) String

func (i Type) String() string

Jump to

Keyboard shortcuts

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