Update flatten object
This commit is contained in:
parent
a6f2556050
commit
0c825b65b0
@ -15,7 +15,7 @@ type ProcessingResource struct {
|
|||||||
Arguments []string `bson:"arguments,omitempty" json:"arguments,omitempty"`
|
Arguments []string `bson:"arguments,omitempty" json:"arguments,omitempty"`
|
||||||
Environment []map[string]string `bson:"environment,omitempty" json:"environment,omitempty"` // a key/value struct is what ressembles the most a NAME=VALUE struct
|
Environment []map[string]string `bson:"environment,omitempty" json:"environment,omitempty"` // a key/value struct is what ressembles the most a NAME=VALUE struct
|
||||||
|
|
||||||
ExecutionRequirements ExecutionRequirementsModel `json:"execution_requirements,omitempty"`
|
ExecutionRequirements *ExecutionRequirementsModel `json:"execution_requirements,omitempty"`
|
||||||
|
|
||||||
Price uint `bson:"price,omitempty" json:"price,omitempty"`
|
Price uint `bson:"price,omitempty" json:"price,omitempty"`
|
||||||
License string `bson:"license,omitempty" json:"license,omitempty"`
|
License string `bson:"license,omitempty" json:"license,omitempty"`
|
||||||
|
@ -28,7 +28,7 @@ func (wfa *WorkflowResourceMongoAccessor) CopyOne(data utils.DBObject) (utils.DB
|
|||||||
return wfa.GenericStoreOne(data, wfa)
|
return wfa.GenericStoreOne(data, wfa)
|
||||||
} else {
|
} else {
|
||||||
data.(*WorkflowResource).UUID = res.GetID()
|
data.(*WorkflowResource).UUID = res.GetID()
|
||||||
return wfa.GenericUpdateOne(data.Serialize(), res.GetID(), wfa)
|
return wfa.GenericUpdateOne(data, res.GetID(), wfa)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +65,17 @@ func (dma *AbstractAccessor) GenericDeleteOne(id string, accessor Accessor) (DBO
|
|||||||
return res, 200, nil
|
return res, 200, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (dma *AbstractAccessor) GenericUpdateOne(set interface{}, id string, accessor Accessor) (DBObject, int, error) {
|
func (dma *AbstractAccessor) GenericUpdateOne(set DBObject, id string, accessor Accessor) (DBObject, int, error) {
|
||||||
id, code, err := mongo.MONGOService.UpdateOne(set, id, accessor.GetType())
|
changeMap := set.Serialize()
|
||||||
|
r, c, err := accessor.LoadOne(id)
|
||||||
|
if err != nil {
|
||||||
|
return nil, c, err
|
||||||
|
}
|
||||||
|
original := r.Serialize()
|
||||||
|
for k, v := range changeMap {
|
||||||
|
original[k] = v
|
||||||
|
}
|
||||||
|
id, code, err := mongo.MONGOService.UpdateOne(set.Deserialize(original), id, accessor.GetType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dma.Logger.Error().Msg("Could not update " + id + " to db. Error: " + err.Error())
|
dma.Logger.Error().Msg("Could not update " + id + " to db. Error: " + err.Error())
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
|
Loading…
Reference in New Issue
Block a user