Apply
This commit is contained in:
@@ -250,7 +250,7 @@ func (a *AbstractAccessor[T]) CopyOne(data DBObject) (DBObject, int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *AbstractAccessor[T]) LoadOne(id string) (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
|
return d, 200, nil
|
||||||
}, a)
|
}, a)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"cloud.o-forge.io/core/oc-lib/dbs"
|
"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 {
|
if err != nil {
|
||||||
return nil, code, err
|
return nil, code, err
|
||||||
}
|
}
|
||||||
|
fmt.Println("APPLY", data)
|
||||||
res_mongo.Decode(&data)
|
res_mongo.Decode(&data)
|
||||||
if a.ShouldVerifyAuth() && !data.VerifyAuth("get", a.GetRequest()) {
|
if a.ShouldVerifyAuth() && !data.VerifyAuth("get", a.GetRequest()) {
|
||||||
return nil, 403, errors.New("you are not allowed to access :" + a.GetType().String())
|
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}},
|
"relation": {{Operator: dbs.EQUAL.String(), Value: 1}},
|
||||||
},
|
},
|
||||||
}, "", false)
|
}, "", false)
|
||||||
if len(datas) > 0 {
|
if len(datas) > 0 && datas[0] != nil {
|
||||||
return datas[0], nil
|
return datas[0], nil
|
||||||
}
|
}
|
||||||
return nil, errors.New("peer not found")
|
return nil, errors.New("peer not found")
|
||||||
|
|||||||
Reference in New Issue
Block a user