mirror of
https://github.com/openziti/ziti.git
synced 2026-09-22 10:33:40 +00:00
6fdd5bcda5
* 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
26 lines
658 B
Go
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
|
|
})
|
|
}
|