datacenter

This commit is contained in:
mr 2024-07-23 14:57:16 +02:00
parent 8fb3e35142
commit 806f5d0f20

View File

@ -2,6 +2,7 @@ package datacenter
import (
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
"cloud.o-forge.io/core/oc-lib/models/resources"
"cloud.o-forge.io/core/oc-lib/models/utils"
)
@ -38,3 +39,18 @@ func (dca *DatacenterMongoAccessor) LoadOne(id string) (utils.DBObject, int, err
return &datacenter, 200, nil
}
func (wfa DatacenterMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
objs := []utils.ShallowDBObject{}
res_mongo, code, err := mongo.MONGOService.LoadAll(wfa.GetType())
if err != nil {
wfa.Logger.Error().Msg("Could not retrieve any from db. Error: " + err.Error())
return nil, code, err
}
for res_mongo.Next(mongo.MngoCtx) {
var obj resources.AbstractResource
res_mongo.Decode(&obj)
objs = append(objs, &obj)
}
return objs, 200, nil
}