Debugging Put / GET ALL

This commit is contained in:
mr 2024-07-24 08:35:41 +02:00
parent b775298bb0
commit bde70dec9b
8 changed files with 46 additions and 29 deletions

View File

@ -44,10 +44,12 @@ func (wfa DataMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error) {
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 DataResource
res_mongo.Decode(&obj)
objs = append(objs, &obj.AbstractResource)
var results []DataResource
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r.AbstractResource)
}
return objs, 200, nil
}

View File

@ -46,10 +46,12 @@ func (wfa DatacenterMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, erro
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 DatacenterResource
res_mongo.Decode(&obj)
objs = append(objs, &obj.AbstractResource)
var results []DatacenterResource
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r.AbstractResource)
}
return objs, 200, nil
}

View File

@ -47,10 +47,12 @@ func (wfa ProcessingMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, erro
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 ProcessingResource
res_mongo.Decode(&obj)
objs = append(objs, &obj.AbstractResource)
var results []ProcessingResource
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r.AbstractResource)
}
return objs, 200, nil
}

View File

@ -47,10 +47,12 @@ func (wfa StorageMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error)
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 StorageResource
res_mongo.Decode(&obj)
objs = append(objs, &obj.AbstractResource)
var results []StorageResource
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r.AbstractResource)
}
return objs, 200, nil
}

View File

@ -50,10 +50,12 @@ func (wfa WorkflowResourceMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int
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 WorkflowResource
res_mongo.Decode(&obj)
objs = append(objs, &obj.AbstractResource)
var results []WorkflowResource
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r.AbstractResource)
}
return objs, 200, nil
}

View File

@ -1,6 +1,8 @@
package utils
import (
"fmt"
"cloud.o-forge.io/core/oc-lib/dbs/mongo"
"cloud.o-forge.io/core/oc-lib/logs"
"github.com/go-playground/validator/v10"
@ -79,7 +81,8 @@ func (dma *AbstractAccessor) GenericUpdateOne(set DBObject, id string, accessor
for k, v := range changeMap {
original[k] = v
}
id, code, err := mongo.MONGOService.UpdateOne(set.Deserialize(original), id, accessor.GetType())
fmt.Println(original)
id, code, err := mongo.MONGOService.UpdateOne(r.Deserialize(original), id, accessor.GetType())
if err != nil {
dma.Logger.Error().Msg("Could not update " + id + " to db. Error: " + err.Error())
return nil, code, err

View File

@ -99,10 +99,12 @@ func (wfa WorkflowMongoAccessor) LoadAll() ([]utils.ShallowDBObject, int, error)
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 Workflow
res_mongo.Decode(&obj)
objs = append(objs, &obj.AbstractObject)
var results []Workflow
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r.AbstractObject)
}
return objs, 200, nil
}

View File

@ -43,10 +43,12 @@ func (wfa WorkflowExecutionMongoAccessor) LoadAll() ([]utils.ShallowDBObject, in
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 utils.AbstractObject
res_mongo.Decode(&obj)
objs = append(objs, &obj)
var results []WorkflowExecution
if err = res_mongo.All(mongo.MngoCtx, &results); err != nil {
return nil, 404, err
}
for _, r := range results {
objs = append(objs, &r)
}
return objs, 200, nil
}