versionx

package
v0.0.0-...-4675295 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseKey

func ParseKey(key string) (className, id string)

Types

type IObject

type IObject interface {
	RefGet(field string) (val interface{})
	RefSet(field string, val interface{})

	// 字段的路径
	RefFieldPath() string
	//
	RefFieldChanged() bool

	RefHas(field string) (val bool)
	// basic
	RefInt(field string) (val int)
	RefFloat64(field string) (val float64)
	RefString(field string) (val string)
	RefBool(field string) (val bool)
	RefArray(field string) datax.A
	RefMap(field string) IObject
	// object
	RefClass(field string) IObject
	RefClassCreator(field string, creator func(object IObject) IObject)

	RefLastVersion() int
	RefVersions() map[string]int
	RefVersionComplete()
	KeyVersionReset()

	// 设置为nil
	RefSetNil()
	RefNew() IObject
	RefNewIfNil() IObject
	RefIsNil() bool
	RefKeys() []string
	RefData() datax.M
	RefLength() int
	RefReset(val map[string]interface{})
	RefUpdate(data map[string]interface{})
	RefRemove(field string)

	//FromMap(m datax.M)
	//fromMap(m datax.M)
	ToMapVersion() (r datax.M)

	ToMap() (r datax.M)

	ToMapByField(fieldMap datax.M) (r datax.M)
	// contains filtered or unexported methods
}

type IRoot

type IRoot interface {
	IObject
	// 获取编号
	// field="_id"
	RefId() string
	RefIdSet(val string)
	RefClone() (r *Root)
	RefIsRemove() bool

	RefDispose()
	RefOnChange(func(path, field string, val interface{}))
	RefReset(val map[string]interface{})
}

type Object

type Object struct {
	*Source
	// contains filtered or unexported fields
}

func NewObject

func NewObject() (obj *Object)

独立用

func (*Object) RefArray

func (s *Object) RefArray(field string) datax.A

func (*Object) RefBool

func (s *Object) RefBool(field string) bool

func (*Object) RefClass

func (s *Object) RefClass(field string) IObject

func (*Object) RefClassCreator

func (s *Object) RefClassCreator(field string, creator func(object IObject) IObject)

func (*Object) RefData

func (s *Object) RefData() datax.M

func (*Object) RefFieldChanged

func (s *Object) RefFieldChanged() bool

实例是否发生变化

func (*Object) RefFieldPath

func (s *Object) RefFieldPath() string

字段的路径

func (*Object) RefFloat64

func (s *Object) RefFloat64(field string) float64

func (*Object) RefGet

func (s *Object) RefGet(field string) (val interface{})

func (*Object) RefHas

func (s *Object) RefHas(field string) bool

func (*Object) RefInt

func (s *Object) RefInt(field string) int

func (*Object) RefIsNil

func (s *Object) RefIsNil() bool

func (*Object) RefKeys

func (s *Object) RefKeys() (r []string)

func (*Object) RefLength

func (s *Object) RefLength() int

func (*Object) RefMap

func (s *Object) RefMap(field string) (r IObject)

func (*Object) RefNew

func (s *Object) RefNew() IObject

新建结构, 旧的数据清除 返回自身,便于链式调用

func (*Object) RefNewIfNil

func (s *Object) RefNewIfNil() IObject

如果是空的才新建结构 返回自身,便于链式调用

func (*Object) RefRemove

func (s *Object) RefRemove(field string)

func (*Object) RefRemoveFromRoot

func (s *Object) RefRemoveFromRoot()

把对象脱离与Root的关联,自己独立成Root,可以避免运行时对Root产生影响

func (*Object) RefReset

func (s *Object) RefReset(data map[string]interface{})

func (*Object) RefSet

func (s *Object) RefSet(field string, val interface{})

只能设置基本类型

func (*Object) RefSetNil

func (s *Object) RefSetNil()

设置成nil

func (*Object) RefString

func (s *Object) RefString(field string) string

func (*Object) RefUint

func (s *Object) RefUint(field string) uint

func (*Object) RefUpdate

func (s *Object) RefUpdate(data map[string]interface{})

func (*Object) ToMap

func (s *Object) ToMap() (r datax.M)

输出所有字段

func (*Object) ToMapByField

func (s *Object) ToMapByField(fieldMap datax.M) (r datax.M)

输出指定字段

func (*Object) ToMapVersion

func (s *Object) ToMapVersion() (r datax.M)

输出变化的字段

type Root

type Root struct {
	*Object
}

func NewRoot

func NewRoot(source *Source) (obj *Root)

func (*Root) RefClone

func (s *Root) RefClone() (r *Root)

func (*Root) RefDispose

func (s *Root) RefDispose()

func (*Root) RefId

func (s *Root) RefId() string

编号

func (*Root) RefIdSet

func (s *Root) RefIdSet(val string)

设置根

func (*Root) RefOnChange

func (s *Root) RefOnChange(f func(path, field string, val interface{}))

func (*Root) RefReset

func (s *Root) RefReset(val map[string]interface{})

type RootMap

type RootMap map[string]IRoot

RootMap只用于管理Root, 便于coder进行处理

func (RootMap) DisposeAll

func (m RootMap) DisposeAll()

func (RootMap) DisposeRemoved

func (m RootMap) DisposeRemoved()

func (RootMap) Get

func (m RootMap) Get(key string) (r IRoot, has bool)

func (RootMap) Remove

func (m RootMap) Remove(key string)

func (RootMap) Set

func (m RootMap) Set(r IRoot)

type Source

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

func NewSource

func NewSource() *Source

func NewSourceWith

func NewSourceWith(origin datax.M) *Source

func (*Source) Clone

func (s *Source) Clone() (r *Source)

func (*Source) Dispose

func (s *Source) Dispose()

func (*Source) KeyVersionNew

func (s *Source) KeyVersionNew(parents []string, path string)

增加字段的版本

func (*Source) KeyVersionReset

func (s *Source) KeyVersionReset()

重置版本号, 所有字段都发生变化

func (*Source) RefIsRemove

func (s *Source) RefIsRemove() bool

func (*Source) RefLastVersion

func (s *Source) RefLastVersion() int

实例最后更新的版本号

func (*Source) RefRemove

func (s *Source) RefRemove()

func (*Source) RefReset

func (s *Source) RefReset(val map[string]interface{})

func (*Source) RefVersionComplete

func (s *Source) RefVersionComplete()

版本更新完成

func (*Source) RefVersions

func (s *Source) RefVersions() (r map[string]int)

实例的版本信息

func (*Source) WithVersion

func (s *Source) WithVersion() *Source

Jump to

Keyboard shortcuts

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