db

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: MIT Imports: 16 Imported by: 2

Documentation

Index

Constants

View Source
const (
	MAX_ARRAY_LENGTH = 64
)

Variables

View Source
var (
	DB *sql.DB
)
View Source
var (
	POOL *redis.Pool
)

Functions

func Delete

func Delete(database int, key string) error

Delete 删除

func DeleteSql added in v0.0.9

func DeleteSql(obj interface{}, params ...OpOption) string

func Do

func Do(database int, pFunc func(c redis.Conn) (reply interface{}, err error)) (reply interface{}, err error)

/Do a func can do no defer close

func Exist

func Exist(database int, key string) bool

IsExist 判断key是否存在

func Expire

func Expire(database, timeout int, key string) error

Expire 超时

func Get

func Get(database int, key string) ([]byte, error)

/Get 获取一个值

func GetDBTimeString added in v0.0.9

func GetDBTimeString(t int64) string

---获取datetime时间

func InsertSql added in v0.0.9

func InsertSql(obj interface{}, params ...OpOption) string

--- struct to sql

func LoadObjSql added in v0.0.9

func LoadObjSql(obj interface{}, row IRow) bool

--- struct to sql

func LoadSql added in v0.0.9

func LoadSql(obj interface{}, params ...OpOption) string

--- struct to sql

func OpenDB added in v0.0.9

func OpenDB(conf common.Mysql) error

func OpenRedisPool

func OpenRedisPool(ip, pwd string) error

@title 启动redis, redispo.Pool(连接池)

func SaveSql added in v0.0.9

func SaveSql(obj interface{}, params ...OpOption) string

--- struct to sql

func SaveSqlStr added in v0.0.9

func SaveSqlStr(sqlData *SqlData) string

func Set

func Set(database int, timeout int, key string, val interface{}) (err error)

Set 设置一个值

func UpdateSql added in v0.0.9

func UpdateSql(obj interface{}, params ...OpOption) string

func WhereSql added in v0.0.9

func WhereSql(obj interface{}, params ...OpOption) string

Types

type Colunm added in v0.0.9

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

type Datetime added in v0.0.9

type Datetime int64

type IRow added in v0.0.9

type IRow interface {
	Set(key, val string)
	Get(key string) string
	String(key string) string
	Int(key string) int
	Int64(key string) int64
	Float32(key string) float32
	Float64(key string) float64
	Bool(key string) bool
	Time(key string) int64
	Byte(key string) []byte
	Obj(obj interface{}) bool
	KV() map[string]string
	// contains filtered or unexported methods
}

type IRows added in v0.0.9

type IRows interface {
	Next() bool
	Row() *Row
	Obj(obj interface{}) bool
}

type Op added in v0.0.9

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

type OpOption added in v0.0.9

type OpOption func(*Op)

func WithForce added in v0.0.9

func WithForce() OpOption

func WithLimit added in v0.0.9

func WithLimit(limit int) OpOption

func WithOutWhere added in v0.0.9

func WithOutWhere() OpOption

func WithWhere added in v0.0.9

func WithWhere(obj interface{}) OpOption

func WithWhereStr added in v0.0.9

func WithWhereStr(str string) OpOption

type PROTYPE added in v0.0.9

type PROTYPE uint

type Properties added in v0.0.9

type Properties struct {
	Name     string
	Primary  bool
	DateTime bool
	Blob     bool
	Json     bool
	Ignore   bool
	Table    bool //table name
	Force    bool //update ignore is zero
	// contains filtered or unexported fields
}

func (*Properties) IsBlob added in v0.0.9

func (this *Properties) IsBlob() bool

二进制 `sql:"blob"`

func (*Properties) IsDatetime added in v0.0.9

func (this *Properties) IsDatetime() bool

日期 `sql:"datetime"`

func (*Properties) IsForce added in v0.0.9

func (this *Properties) IsForce() bool

is zero can update tablename `sql:"force"`

func (*Properties) IsIgnore added in v0.0.9

func (this *Properties) IsIgnore() bool

ignore `sql:"-"`

func (*Properties) IsJson added in v0.0.9

func (this *Properties) IsJson() bool

json `sql:"json"`

func (*Properties) IsPrimary added in v0.0.9

func (this *Properties) IsPrimary() bool

主键 `sql:"primary"`

func (*Properties) IsTable added in v0.0.9

func (this *Properties) IsTable() bool

tablename `sql:"table"`

type Row added in v0.0.9

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

func NewRow added in v0.0.9

func NewRow() *Row

func (*Row) Bool added in v0.0.9

func (this *Row) Bool(key string) bool

func (*Row) Byte added in v0.0.9

func (this *Row) Byte(key string) []byte

func (*Row) Float32 added in v0.0.9

func (this *Row) Float32(key string) float32

func (*Row) Float64 added in v0.0.9

func (this *Row) Float64(key string) float64

func (*Row) Get added in v0.0.9

func (this *Row) Get(key string) string

func (*Row) Int added in v0.0.9

func (this *Row) Int(key string) int

func (*Row) Int64 added in v0.0.9

func (this *Row) Int64(key string) int64

func (*Row) KV added in v0.0.9

func (this *Row) KV() map[string]string

func (*Row) Obj added in v0.0.9

func (this *Row) Obj(obj interface{}) bool

func (*Row) Set added in v0.0.9

func (this *Row) Set(key, val string)

func (*Row) String added in v0.0.9

func (this *Row) String(key string) string

func (*Row) Time added in v0.0.9

func (this *Row) Time(key string) int64

type Rows added in v0.0.9

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

func Query added in v0.0.9

func Query(rows *sql.Rows, err error) (*Rows, error)

func (*Rows) Next added in v0.0.9

func (this *Rows) Next() bool

func (*Rows) Obj added in v0.0.9

func (this *Rows) Obj(obj interface{}) bool

func (*Rows) Row added in v0.0.9

func (this *Rows) Row() *Row

type SQLTYPE added in v0.0.9

type SQLTYPE int
const (
	SQLTYPE_INSERT SQLTYPE = iota
	SQLTYPE_DELETE SQLTYPE = iota
	SQLTYPE_UPDATE SQLTYPE = iota
	SQLTYPE_LOAD   SQLTYPE = iota
	SQLTYPE_SAVE   SQLTYPE = iota
	SQLTYPE_WHERE  SQLTYPE = iota
)

type SqlData added in v0.0.9

type SqlData struct {
	Name      string
	Value     string
	Key       string
	NameValue string
	Table     string
	// contains filtered or unexported fields
}

type Table added in v0.0.9

type Table struct {
	Name    string
	Columns []*Properties
}

Jump to

Keyboard shortcuts

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