From b5dba2458ad472da5634c4fc007450b865cb5ab6 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 12 Nov 2024 12:45:03 +0100 Subject: [PATCH] state execution --- models/utils/abstracts.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/models/utils/abstracts.go b/models/utils/abstracts.go index 2f6dd5a..86d4738 100644 --- a/models/utils/abstracts.go +++ b/models/utils/abstracts.go @@ -160,3 +160,14 @@ func (dma *AbstractAccessor) GenericUpdateOne(set DBObject, id string, accessor } return accessor.LoadOne(id) } + +// GenericLoadOne loads one object from the database (generic) +// json expected in entry is a flatted object no need to respect the inheritance hierarchy +func (dma *AbstractAccessor) GenericRawUpdateOne(set DBObject, id string, accessor Accessor, new DBObject) (DBObject, int, error) { + id, code, err := mongo.MONGOService.UpdateOne(set, id, accessor.GetType()) + if err != nil { + dma.Logger.Error().Msg("Could not update " + id + " to db. Error: " + err.Error()) + return nil, code, err + } + return accessor.LoadOne(id) +}