oc-lib/models/utils/interfaces.go

37 lines
961 B
Go

package utils
import (
"cloud.o-forge.io/core/oc-lib/dbs"
"cloud.o-forge.io/core/oc-lib/tools"
)
type ShallowDBObject interface {
GenerateID()
GetID() string
GetName() string
Deserialize(j map[string]interface{}) DBObject
Serialize() map[string]interface{}
}
type DBObject interface {
GenerateID()
GetID() string
GetName() string
Deserialize(j map[string]interface{}) DBObject
Serialize() map[string]interface{}
GetAccessor(caller *tools.HTTPCaller) Accessor
}
type Accessor interface {
Init(t DataType, caller *tools.HTTPCaller)
GetType() string
GetCaller() *tools.HTTPCaller
Search(filters *dbs.Filters, search string) ([]ShallowDBObject, int, error)
LoadAll() ([]ShallowDBObject, int, error)
LoadOne(id string) (DBObject, int, error)
DeleteOne(id string) (DBObject, int, error)
CopyOne(data DBObject) (DBObject, int, error)
StoreOne(data DBObject) (DBObject, int, error)
UpdateOne(set DBObject, id string) (DBObject, int, error)
}