default on serialization
This commit is contained in:
@@ -120,13 +120,23 @@ func ModelGenericUpdateOne(change map[string]interface{}, id string, a Accessor)
|
||||
for k, v := range change { // apply the changes, with a flatten method
|
||||
loaded[k] = v
|
||||
}
|
||||
return r, loaded, 200, nil
|
||||
newObj := a.NewObj()
|
||||
b, err = json.Marshal(loaded)
|
||||
if err != nil {
|
||||
return nil, loaded, 400, nil
|
||||
}
|
||||
err = json.Unmarshal(b, newObj)
|
||||
if err != nil {
|
||||
return nil, loaded, 400, nil
|
||||
}
|
||||
return newObj, loaded, 200, nil
|
||||
}
|
||||
|
||||
// GenericLoadOne loads one object from the database (generic)
|
||||
// json expected in entry is a flatted object no need to respect the inheritance hierarchy
|
||||
func GenericUpdateOne(change map[string]interface{}, id string, a Accessor) (DBObject, int, error) {
|
||||
obj, loaded, c, err := ModelGenericUpdateOne(change, id, a)
|
||||
|
||||
if err != nil {
|
||||
return nil, c, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user