qdao

package
v0.0.0-...-4155a33 Latest Latest
Warning

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

Go to latest
Published: May 26, 2020 License: MIT Imports: 8 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListAll

func ListAll(dao D, db string, group string, from int, size int, unmarshal int, opt QOpt) (data []interface{}, err error)

Types

type Config

type Config struct {
	Name        string
	Type        string
	Host        string
	Port        int
	User        string
	Pass        string
	Database    string
	MaxIdle     int
	KeepAlive   int
	IdleTimeout int
	Extra       map[string]interface{}
	Options     map[string]interface{}
	DBMapping   map[string]interface{}
	Framework   *Schema
	// contains filtered or unexported fields
}

func (*Config) Configure

func (o *Config) Configure(
	name string, daotype string,
	host string, port int, user string, pass string, database string,
	options map[string]interface{}) error

func (*Config) Lock

func (o *Config) Lock()

func (*Config) RLock

func (o *Config) RLock()

func (*Config) RUnLock

func (o *Config) RUnLock()

func (*Config) UnLock

func (o *Config) UnLock()

type D

type D interface {
	Configure(
		name string, daotype string,
		host string, port int, user string, pass string, database string,
		options map[string]interface{}) error

	Conn() (agent interface{}, err error)
	Close() error
	IsConnected() bool

	Agent() (agent interface{}, err error)

	SelectDB(db string) error

	UpdateDB(db string, options interface{}, create bool, override bool, opt UOpt) (interface{}, error)
	UpdateGroup(db string, group string, options interface{}, create bool, override bool, opt UOpt) (interface{}, error)

	Exists(db string, group string, ids []interface{}) (int64, error)
	ExistDB(db string) (bool, error)
	ExistGroup(db string, group string) (bool, error)

	GetDB(db string, opt QOpt) (interface{}, error)
	GetGroup(db string, group string, opt QOpt) (interface{}, error)

	Keys(db string, group string, wildcard string, opt QOpt) (keys []string, err error)

	Get(db string, group string, id interface{}, unmarshal int, opt QOpt) (ret interface{}, err error)
	Gets(db string, group string, ids []interface{}, unmarshal int, opt QOpt) (rets []interface{}, err error)
	List(db string, group string, from int, size int, unmarshal int, opt QOpt) (rets []interface{}, cursor int, err error)
	Query(db string, query string, args []interface{}, opt QOpt) (interface{}, error)

	Update(db string, group string, id interface{}, val interface{}, override bool, marshal int, opt UOpt) (interface{}, error)
	Updates(db string, group string, ids []interface{}, vals []interface{}, override bool, marshal int, opt UOpt) (interface{}, error)
	UpdateBatch(db string, groups []string, ids []interface{}, vals []interface{}, override bool, marshal int, opt UOpt) (interface{}, error)

	Delete(db string, group string, id interface{}, opt DOpt) (interface{}, error)
	Deletes(db string, group string, ids []interface{}, opt DOpt) (interface{}, error)

	Script(db string, group string, id interface{}, script string, args []interface{}, opt QOpt) (interface{}, error)
}

type DBSchema

type DBSchema struct {
	Name  string
	Group map[string]*GroupSchema
	Root  *Schema
}

func (*DBSchema) Init

func (db *DBSchema) Init(name string, dbOptions map[string]interface{})

type DOpt

type DOpt map[string]interface{}

type DaoManager

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

func GetManager

func GetManager() *DaoManager

func (*DaoManager) Destroy

func (o *DaoManager) Destroy()

func (*DaoManager) Get

func (o *DaoManager) Get(id string) (dao D, err error)

func (*DaoManager) GetSchema

func (o *DaoManager) GetSchema() *Schema

func (*DaoManager) Init

func (o *DaoManager) Init(producer DaoProducer, schemaOpts map[string]interface{}, databaseOpts map[string]interface{}) error

func (*DaoManager) InitDao

func (o *DaoManager) InitDao(name string, options map[string]interface{}) (D, error)

func (*DaoManager) Release

func (o *DaoManager) Release(id string)

func (*DaoManager) Terminate

func (o *DaoManager) Terminate() error

type DaoProducer

type DaoProducer func(manager *DaoManager, name string, opts map[string]interface{}) (D, error)

type FieldSchema

type FieldSchema struct {
	Name     string
	Type     VType
	TypeCode VTypeCode
	Factor   VFactor
	Format   string
	Group    *GroupSchema
	Parent   *FieldSchema
	Sub      map[string]*FieldSchema
}

func (*FieldSchema) Init

func (field *FieldSchema) Init(name string, fieldOpts interface{})

type GroupSchema

type GroupSchema struct {
	Name  string
	Key   *FieldSchema
	Field map[string]*FieldSchema
	DB    *DBSchema
}

func (*GroupSchema) Init

func (group *GroupSchema) Init(name string, groupOptions map[string]interface{})

type QOpt

type QOpt map[string]interface{}

func (QOpt) GetFields

func (o QOpt) GetFields() []string

func (QOpt) SetFields

func (o QOpt) SetFields(fields []string)

type Schema

type Schema struct {
	Name string
	DB   map[string]*DBSchema
	// contains filtered or unexported fields
}

func (*Schema) GetField

func (s *Schema) GetField(db string, group string, field string) *FieldSchema

func (*Schema) GetGroup

func (s *Schema) GetGroup(db string, group string) *GroupSchema

func (*Schema) GetGroupKey

func (s *Schema) GetGroupKey(db string, group string, def string) string

func (*Schema) Init

func (s *Schema) Init(name string, schemaOptions map[string]interface{})

type UOpt

type UOpt map[string]interface{}

type VFactor

type VFactor int
const (
	VFACTOR_NORMAL VFactor = 0
	VFACTOR_KEY    VFactor = 1
)

type VType

type VType string
const (
	VTYPE_BOOL   VType = "bool"
	VTYPE_INT    VType = "int"
	VTYPE_TIME   VType = "time"
	VTYPE_FLOAT  VType = "float"
	VTYPE_ARRAY  VType = "array"
	VTYPE_OBJECT VType = "object"
	VTYPE_STRING VType = "string"
	VTYPE_BINARY VType = "binary"
)

type VTypeCode

type VTypeCode int
const (
	VTYPE_CODE_BOOL   VTypeCode = 1
	VTYPE_CODE_INT    VTypeCode = 2
	VTYPE_CODE_TIME   VTypeCode = 3
	VTYPE_CODE_FLOAT  VTypeCode = 4
	VTYPE_CODE_ARRAY  VTypeCode = 5
	VTYPE_CODE_OBJECT VTypeCode = 6
	VTYPE_CODE_STRING VTypeCode = 7
	VTYPE_CODE_BINARY VTypeCode = 8
)

func GetVTypeCode

func GetVTypeCode(vtype VType) VTypeCode

Jump to

Keyboard shortcuts

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