diff --git a/models/utils/abstracts.go b/models/utils/abstracts.go index 684f09b..9f10f71 100755 --- a/models/utils/abstracts.go +++ b/models/utils/abstracts.go @@ -250,7 +250,7 @@ func (a *AbstractAccessor[T]) CopyOne(data DBObject) (DBObject, int, error) { } func (a *AbstractAccessor[T]) LoadOne(id string) (DBObject, int, error) { - return GenericLoadOne[T](id, a.New(), func(d DBObject) (DBObject, int, error) { + return GenericLoadOne(id, a.New(), func(d DBObject) (DBObject, int, error) { return d, 200, nil }, a) } diff --git a/models/utils/common.go b/models/utils/common.go index 797599e..35fc726 100755 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -2,6 +2,7 @@ package utils import ( "errors" + "fmt" "os" "cloud.o-forge.io/core/oc-lib/dbs" @@ -131,6 +132,7 @@ func GenericLoadOne[T DBObject](id string, data T, f func(DBObject) (DBObject, i if err != nil { return nil, code, err } + fmt.Println("APPLY", data) res_mongo.Decode(&data) if a.ShouldVerifyAuth() && !data.VerifyAuth("get", a.GetRequest()) { return nil, 403, errors.New("you are not allowed to access :" + a.GetType().String()) @@ -187,7 +189,7 @@ func GetMySelf(wfa Accessor) (ShallowDBObject, error) { "relation": {{Operator: dbs.EQUAL.String(), Value: 1}}, }, }, "", false) - if len(datas) > 0 { + if len(datas) > 0 && datas[0] != nil { return datas[0], nil } return nil, errors.New("peer not found")