diff --git a/models/utils/abstracts.go b/models/utils/abstracts.go index 6ad9bce..a6d612e 100755 --- a/models/utils/abstracts.go +++ b/models/utils/abstracts.go @@ -176,6 +176,10 @@ type AbstractAccessor[T DBObject] struct { NotImplemented []string } +func (r *AbstractAccessor[T]) NewObj() DBObject { + return r.New() +} + func (r *AbstractAccessor[T]) ShouldVerifyAuth() bool { return true } diff --git a/models/utils/common.go b/models/utils/common.go index 4a0808f..a196317 100755 --- a/models/utils/common.go +++ b/models/utils/common.go @@ -97,7 +97,7 @@ func ModelGenericUpdateOne(change map[string]interface{}, id string, a Accessor) if err != nil { return nil, nil, c, err } - obj := &AbstractObject{} + obj := a.NewObj() b, _ := json.Marshal(r) json.Unmarshal(b, obj) ok, r := r.CanUpdate(obj) diff --git a/models/utils/interfaces.go b/models/utils/interfaces.go index 579d78b..63eb6f7 100755 --- a/models/utils/interfaces.go +++ b/models/utils/interfaces.go @@ -40,6 +40,7 @@ type DBObject interface { // Accessor is an interface that defines the basic methods for an Accessor type Accessor interface { + NewObj() DBObject GetUser() string GetPeerID() string GetGroups() []string