eav

package
v0.8.13 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddValue

func AddValue[T ValueType](m *Module, entity, attr int64, val T) (int64, error)

func DelValue

func DelValue[T ValueType](m *Module, id int64) error

func GetValue

func GetValue[T ValueType](m *Module, id int64) (T, error)

GetValue 获得 id 对应的值

NOTE: 该操作不会考虑 id 是否已经被删除。

func SetValue

func SetValue[T ValueType](m *Module, id int64, val T) error

Types

type AttributeVO

type AttributeVO struct {
	ID   int64  `json:"id" yaml:"id" xml:"id" yaml:"id" orm:"name(id)"`
	Name string `json:"name" yaml:"name" xml:"name" yaml:"name" orm:"name(name)"`
}

type Module

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

func Install

func Install(mod *cmfx.Module, prefix string) *Module

func Load

func Load(mod *cmfx.Module, prefix string) *Module

func (*Module) AddAttribute

func (m *Module) AddAttribute(name string) (int64, error)

func (*Module) DelAttribute

func (m *Module) DelAttribute(id int64) error

func (*Module) GetAttribute

func (m *Module) GetAttribute(id int64) (string, error)

GetAttribute 获取属性 id 对应的名称

NOTE: 该操作不会考虑 id 是否已经被删除,如果不存在返回空字符串。

func (*Module) GetAttributes

func (m *Module) GetAttributes() ([]*AttributeVO, error)

func (*Module) SetAttribute

func (m *Module) SetAttribute(id int64, name string) error

type ValueType

type ValueType interface {
	~int64 | ~string | time.Time | *time.Time | ~float64
}

type ValueVO

type ValueVO[T ValueType] struct {
	ID    int64 `json:"id" yaml:"id" xml:"id" yaml:"id" orm:"name(id)"`
	Value T     `json:"value" yaml:"value" xml:"value" yaml:"value" orm:"name(value)"`
}

func GetValues

func GetValues[T ValueType](m *Module, entity, attr int64) ([]*ValueVO[T], error)

Jump to

Keyboard shortcuts

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