determine returnal
This commit is contained in:
@@ -4,40 +4,50 @@ import (
|
||||
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
|
||||
"cloud.o-forge.io/core/oc-lib/models"
|
||||
"cloud.o-forge.io/core/oc-lib/models/resources"
|
||||
"cloud.o-forge.io/core/oc-lib/models/utils"
|
||||
)
|
||||
|
||||
type LibData int
|
||||
type LibDataEnum int
|
||||
|
||||
const (
|
||||
INVALID LibData = iota
|
||||
DATA = resources.DATA
|
||||
PROCESSING = resources.PROCESSING
|
||||
STORAGE = resources.STORAGE
|
||||
DATACENTER = resources.DATACENTER
|
||||
WORKFLOW = resources.WORKFLOW
|
||||
INVALID LibDataEnum = iota
|
||||
DATA = resources.DATA
|
||||
PROCESSING = resources.PROCESSING
|
||||
STORAGE = resources.STORAGE
|
||||
DATACENTER = resources.DATACENTER
|
||||
WORKFLOW = resources.WORKFLOW
|
||||
)
|
||||
|
||||
func (d LibData) EnumIndex() int {
|
||||
func (d LibDataEnum) EnumIndex() int {
|
||||
return int(d)
|
||||
}
|
||||
|
||||
type LibData struct {
|
||||
Data utils.DBObject `bson:"data" json:"data"`
|
||||
Err error `bson:"error" json:"error"`
|
||||
}
|
||||
|
||||
func Init() {
|
||||
mongo.MONGOService.Init(models.GetModelsNames(), GetConfig())
|
||||
}
|
||||
|
||||
func LoadOne(col LibData, id string) interface{} {
|
||||
return models.Model(col.EnumIndex()).GetAccessor().LoadOne(id)
|
||||
func LoadOne(col LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(col.EnumIndex()).GetAccessor().LoadOne(id)
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
func UpdateOne(col LibData, set map[string]interface{}, id string) interface{} {
|
||||
return models.Model(col.EnumIndex()).GetAccessor().UpdateOne(set, id)
|
||||
func UpdateOne(col LibDataEnum, set map[string]interface{}, id string) LibData {
|
||||
d, err := models.Model(col.EnumIndex()).GetAccessor().UpdateOne(set, id)
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
func DeleteOne(col LibData, id string) interface{} {
|
||||
return models.Model(col.EnumIndex()).GetAccessor().DeleteOne(id)
|
||||
func DeleteOne(col LibDataEnum, id string) LibData {
|
||||
d, err := models.Model(col.EnumIndex()).GetAccessor().DeleteOne(id)
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
func StoreOne(col LibData, object map[string]interface{}) interface{} {
|
||||
func StoreOne(col LibDataEnum, object map[string]interface{}) LibData {
|
||||
model := models.Model(col.EnumIndex())
|
||||
return model.GetAccessor().StoreOne(model.Deserialize(object))
|
||||
d, err := model.GetAccessor().StoreOne(model.Deserialize(object))
|
||||
return LibData{Data: d, Err: err}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user