micro/model/model.go

36 lines
847 B
Go
Raw Permalink Normal View History

// +build ignore
2020-07-08 14:57:45 +01:00
// Package model is an interface for data modelling
package model
// Model provides an interface for data modelling
type Model interface {
// Initialise options
Init(...Option) error
// NewEntity creates a new entity to store or access
NewEntity(name string, value interface{}) Entity
// Create a value
Create(Entity) error
// Read values
Read(...ReadOption) ([]Entity, error)
// Update the value
Update(Entity) error
// Delete an entity
Delete(...DeleteOption) error
// Implementation of the model
String() string
}
type Entity interface {
// Unique id of the entity
Id() string
2020-07-08 15:09:18 +01:00
// Name of the entity
Name() string
2020-07-08 14:57:45 +01:00
// The value associated with the entity
Value() interface{}
// Attributes of the entity
2020-07-08 14:57:45 +01:00
Attributes() map[string]interface{}
2020-07-08 15:09:18 +01:00
// Read a value as a concrete type
Read(v interface{}) error
2020-07-08 14:57:45 +01:00
}