This commit is contained in:
mr
2026-03-04 12:18:13 +01:00
parent 542b0b73ab
commit f033182382
2 changed files with 4 additions and 2 deletions

View File

@@ -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)
}

View File

@@ -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")