entity

package
v0.0.0-...-a57500f Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: MIT Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrItemNotFound      = errors.New("item not found")
	ErrItemAlreadyExists = errors.New("item already exists")
	ErrCantGenId         = errors.New("can't generate item id")
)

Functions

This section is empty.

Types

type Entity

type Entity interface {
	Id() EntityId
	GetAttribute(attrName string, defValue ...string) string
	SetAttribute(attrName string, value string)
}

type EntityId

type EntityId string

func NewEntityId

func NewEntityId() (EntityId, error)

type EntityItem

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

func (*EntityItem) GetAttribute

func (e *EntityItem) GetAttribute(attrName string, defValue ...string) string

func (*EntityItem) Id

func (e *EntityItem) Id() EntityId

func (*EntityItem) SetAttribute

func (e *EntityItem) SetAttribute(attrName string, value string)

type EntityItemList

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

func NewEntityItemList

func NewEntityItemList() *EntityItemList

func (*EntityItemList) GetByAttributes

func (m *EntityItemList) GetByAttributes(attrNames []string, attrValues []string) []EntityId

func (*EntityItemList) GetById

func (m *EntityItemList) GetById(id EntityId) (*EntityItem, error)

func (*EntityItemList) ItemsCount

func (m *EntityItemList) ItemsCount() int

func (*EntityItemList) NewItem

func (m *EntityItemList) NewItem(id ...EntityId) (*EntityItem, error)

func (*EntityItemList) ReadFrom

func (m *EntityItemList) ReadFrom(db kvdb.KeyValueDB, key string) error

func (*EntityItemList) RemoveItem

func (m *EntityItemList) RemoveItem(id EntityId) (*EntityItem, error)

func (*EntityItemList) WriteTo

func (m *EntityItemList) WriteTo(db kvdb.KeyValueDB, key string) error

type EntityList

type EntityList interface {
	ItemsCount() int
	GetByAttributes(attrNames []string, attrValues []string) []EntityId
}

type GetEntitiesByAttributesParams

type GetEntitiesByAttributesParams struct {
	AttrNames []string
	Values    []string
}

type GetEntityAttributeParams

type GetEntityAttributeParams struct {
	Id       EntityId
	AttrName string
	DefValue string
}

type SetEntityAttributeParams

type SetEntityAttributeParams struct {
	Id       EntityId
	AttrName string
	Value    string
}

Jump to

Keyboard shortcuts

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