DBAbstract

This commit is contained in:
mr
2026-03-19 11:32:51 +01:00
parent 93ad8db9a8
commit 6641d38d9d
3 changed files with 6 additions and 1 deletions

View File

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

View File

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

View File

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