Update try

This commit is contained in:
mr
2026-03-02 15:46:05 +01:00
parent cb3771c17a
commit 44812309db
19 changed files with 64 additions and 80 deletions

View File

@@ -55,12 +55,10 @@ func NewAccessor[T ResourceInterface](t tools.DataType, request *tools.APIReques
* Nothing special here, just the basic CRUD operations
*/
func (dca *ResourceMongoAccessor[T]) UpdateOne(set utils.DBObject, id string) (utils.DBObject, int, error) {
func (dca *ResourceMongoAccessor[T]) UpdateOne(set map[string]interface{}, id string) (utils.DBObject, int, error) {
if dca.GetType() == tools.COMPUTE_RESOURCE {
return nil, 404, errors.New("can't update a non existing computing units resource not reported onto compute units catalog")
}
set.(T).Trim()
if d, c, err := utils.GenericUpdateOne(set, id, dca, dca.generateData()); err != nil {
return d, c, err
} else {
@@ -72,7 +70,6 @@ func (dca *ResourceMongoAccessor[T]) StoreOne(data utils.DBObject) (utils.DBObje
if dca.GetType() == tools.COMPUTE_RESOURCE {
return nil, 404, errors.New("can't create a non existing computing units resource not reported onto compute units catalog")
}
data.(T).Trim()
return utils.GenericStoreOne(data, dca)
}