data

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2023 License: MIT Imports: 7 Imported by: 11

README

data

chefgo data module.

Documentation

Index

Constants

View Source
const (
	CreateTrigger  = "$.data.create"
	ChangeTrigger  = "$.data.change"
	RemoveTrigger  = "$.data.remove"
	RecoverTrigger = "$.data.recover"
)
View Source
const (
	NAME = "DATA"
)

Variables

This section is empty.

Functions

func Configure

func Configure(cfg Map)

Configure 更新配置

func Field

func Field(name string, field string, exts ...Any) Var

func Fields

func Fields(name string, keys []string, exts ...Vars) Vars

func Go

func Go()

Go 直接开跑 此方法只单独使用模块时用

func Models

func Models() map[string]Model

func Option

func Option(name string, field string, key string) Any

func Options

func Options(name string, field string) Map

func ParseSQL

func ParseSQL(args ...Any) (string, []Any, string, error)

func Ready

func Ready()

Ready 准备运行 此方法只单独使用模块时用

func Register

func Register(name string, value Any, overrides ...bool)

Register 开放给外

func Tables

func Tables() map[string]Table

func Trigger

func Trigger(name string, values ...Map)

接收回来触发器

func Views

func Views() map[string]View

Types

type BatchFunc

type BatchFunc func() Res

type Config

type Config struct {
	Driver  string
	Url     string
	Serial  string
	Setting Map
}

type Configs

type Configs map[string]Config

type Connect

type Connect interface {
	Open() error
	Health() (Health, error)
	Close() error

	Base() DataBase
}

Connect 会话连接

type DataBase

type DataBase interface {
	Close() error
	Erred() error

	Table(name string) DataTable
	View(name string) DataView
	Model(name string) DataModel

	Serial(key string, start, step int64) int64
	Break(key string)

	//开启手动提交事务模式
	Begin() (*sql.Tx, error)
	Submit() error
	Cancel() error
	Batch(BatchFunc) Res
}

func Base

func Base(names ...string) DataBase

type DataModel

type DataModel interface {
	First(args ...Any) Map
	Query(args ...Any) []Map
}

数据模型接口

type DataTable

type DataTable interface {
	Create(Map) Map
	Change(Map, Map) Map
	Remove(...Any) Map
	Update(sets Map, args ...Any) int64
	Delete(args ...Any) int64

	Entity(Any) Map
	Count(args ...Any) float64
	First(args ...Any) Map
	Query(args ...Any) []Map
	Limit(offset, limit Any, args ...Any) (int64, []Map)
	Group(field string, args ...Any) []Map
}

type DataView

type DataView interface {
	Count(args ...Any) float64
	First(args ...Any) Map
	Query(args ...Any) []Map
	Limit(offset, limit Any, args ...Any) (int64, []Map)
	Group(field string, args ...Any) []Map
}

数据视图接口

type Driver

type Driver interface {
	Connect(name string, config Config) (Connect, error)
}

Driver 数据驱动

type Health

type Health struct {
	Workload int64
}

type Instance

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

type Model

type Model struct {
	Name    string `json:"name"`
	Text    string `json:"text"`
	Model   string `json:"model"`
	Key     string `json:"key"`
	Fields  Vars   `json:"fields"`
	Setting Map    `toml:"setting"`
}

func GetModel

func GetModel(name string) *Model

type Module

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

func (*Module) Base

func (this *Module) Base(names ...string) DataBase

返回数据Base对象

func (*Module) Config

func (this *Module) Config(name string, config Config, override bool)

func (*Module) Configs

func (this *Module) Configs(config Configs, override bool)

func (*Module) Configure

func (this *Module) Configure(global Map)

func (*Module) Connect

func (this *Module) Connect()

func (*Module) Driver

func (module *Module) Driver(name string, driver Driver, override bool)

Driver 注册驱动

func (*Module) Field

func (this *Module) Field(name string, field string, extends ...Any) Var

func (*Module) Fields

func (this *Module) Fields(name string, keys []string, extends ...Vars) Vars

func (*Module) Initialize

func (this *Module) Initialize()

func (*Module) Instance

func (this *Module) Instance(names ...string) Instance

Instance

func (*Module) Launch

func (this *Module) Launch()

func (*Module) Model

func (this *Module) Model(name string, config Model, override bool)

注册模型

func (*Module) ModelConfig

func (this *Module) ModelConfig(name string) *Model

func (*Module) ModelFields

func (this *Module) ModelFields(name string, keys []string, exts ...Vars) Vars

func (*Module) ModelOptions

func (this *Module) ModelOptions(name, field string) Map

func (*Module) Models

func (this *Module) Models() map[string]Model

func (*Module) Option

func (this *Module) Option(name, field, key string) Any

func (*Module) Options

func (this *Module) Options(name, field string) Map

func (*Module) Parse

func (this *Module) Parse(args ...Any) (string, []Any, string, error)

查询语法解析器 字段包裹成 $field$ 请自行处理 如mysql为反引号`field`,postgres, oracle为引号"field", 所有参数使用问号(?)表示 postgres驱动需要自行处理转成 $1,$2这样的 oracle驱动需要自行处理转成 :1 :2这样的 mongodb不适用,需驱动自己实现

func (*Module) Register

func (this *Module) Register(key string, value Any, override bool)

func (*Module) Table

func (this *Module) Table(name string, config Table, override bool)

func (*Module) TableConfig

func (this *Module) TableConfig(name string) *Table

func (*Module) TableFields

func (this *Module) TableFields(name string, keys []string, extends ...Vars) Vars

func (*Module) TableOptions

func (this *Module) TableOptions(name, field string) Map

2021-03-04支持一级子字段的option

func (*Module) Tables

func (this *Module) Tables() map[string]Table

func (*Module) Terminate

func (this *Module) Terminate()

func (*Module) View

func (this *Module) View(name string, config View, override bool)

func (*Module) ViewConfig

func (this *Module) ViewConfig(name string) *View

func (*Module) ViewFields

func (this *Module) ViewFields(name string, keys []string, exts ...Vars) Vars

func (*Module) ViewOptions

func (this *Module) ViewOptions(name, field string) Map

func (*Module) Views

func (this *Module) Views() map[string]View

type Relate

type Relate struct {
	Key, Field, Status, Type string
}

type Table

type Table struct {
	Name    string `json:"name"`
	Text    string `json:"text"`
	Schema  string `json:"schema"`
	Table   string `json:"table"`
	Key     string `json:"key"`
	Fields  Vars   `json:"fields"`
	Setting Map    `toml:"setting"`
}

func GetTable

func GetTable(name string) *Table

type View

type View struct {
	Name    string `json:"name"`
	Text    string `json:"text"`
	Schema  string `json:"schema"`
	View    string `json:"view"`
	Key     string `json:"key"`
	Fields  Vars   `json:"fields"`
	Setting Map    `toml:"setting"`
}

func GetView

func GetView(name string) *View

Jump to

Keyboard shortcuts

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