This commit is contained in:
mr 2024-12-02 16:26:44 +01:00
parent 9a2ed2351d
commit e2ddd7e4e6

View File

@ -425,19 +425,15 @@ func (r *Request) StoreOne(object map[string]interface{}) (data LibData) {
* @param c ...*tools.HTTPCaller
* @return data LibData
*/
func (r *Request) CopyOne(collection LibDataEnum, object map[string]interface{}, peerID string, groups []string, c ...*tools.HTTPCaller) (data LibData) {
func (r *Request) CopyOne(object map[string]interface{}) (data LibData) {
defer func() { // recover the panic
if r := recover(); r != nil {
tools.UncatchedError = append(tools.UncatchedError, errors.New("Panic recovered in CopyOne : "+fmt.Sprintf("%v", r)+" - "+string(debug.Stack())))
data = LibData{Data: nil, Code: 500, Err: "Panic recovered in UpdateOne : " + fmt.Sprintf("%v", r) + " - " + string(debug.Stack())}
}
}()
var caller *tools.HTTPCaller // define the caller
if len(c) > 0 {
caller = c[0]
}
model := models.Model(collection.EnumIndex())
d, code, err := model.GetAccessor(peerID, groups, caller).CopyOne(model.Deserialize(object, model))
model := models.Model(r.collection.EnumIndex())
d, code, err := model.GetAccessor(r.peerID, r.groups, r.caller).CopyOne(model.Deserialize(object, model))
if err != nil {
data = LibData{Data: d, Code: code, Err: err.Error()}
return