Files
ziti/controller/controllers/common.go
T
Paul Lorenz 6fdd5bcda5 Add support for multiple endpoints to services and sync model abstrac… (#53)
* Add support for multiple terminators to services and sync model abstractions with edge

* Add Snapshot to db.Db

* Make API friendly errors

* Add association querying. Consolidate Entity* interfaces
2020-03-19 13:23:16 -04:00

26 lines
658 B
Go

package controllers
import (
"github.com/michaelquigley/pfxlog"
"github.com/netfoundry/ziti-foundation/storage/boltz"
"go.etcd.io/bbolt"
)
func DeleteEntityById(store boltz.CrudStore, db boltz.Db, id string) error {
return db.Update(func(tx *bbolt.Tx) error {
ctx := boltz.NewMutateContext(tx)
if !store.IsEntityPresent(tx, id) {
return boltz.NewNotFoundError(store.GetSingularEntityType(), "id", id)
}
if err := store.DeleteById(ctx, id); err != nil {
pfxlog.Logger().
WithField("id", id).
WithField("type", store.GetSingularEntityType()).
WithError(err).Error("could not delete by id")
return err
}
return nil
})
}