eav

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package eav Entity-Attribute-Values 数据表管理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddValue

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

func DelValue

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

func GetValue

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

GetValue 获得 id 对应的值

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

func SetValue

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

Types

type AttributeVO

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

type EAVs added in v0.13.0

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

EAVs 提供 Entity-Attribute-Values 数据表管理

func Install

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

func NewEAVs added in v0.13.0

func NewEAVs(mod *cmfx.Module, prefix string) *EAVs

func (*EAVs) AddAttribute added in v0.13.0

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

func (*EAVs) DelAttribute added in v0.13.0

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

func (*EAVs) GetAttribute added in v0.13.0

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

GetAttribute 获取属性 id 对应的名称

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

func (*EAVs) GetAttributes added in v0.13.0

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

func (*EAVs) SetAttribute added in v0.13.0

func (m *EAVs) 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" cbor:"id" orm:"name(id)"`
	Value T     `json:"value" yaml:"value" cbor:"value" orm:"name(value)"`
}

func GetValues

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

Jump to

Keyboard shortcuts

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