func (db *DB) DeleteEntity(ID string) error {
	err := db.kv.Del(path.Join("/entities", ID))
	if err == ErrNoValue {
		return ErrUnknownEntity
	}
	return err
}
DeleteEntity tries to delete an entity that already exists.
package db
import (
	"path"
	"github.com/hashicorp/go-hclog"
	"google.golang.org/protobuf/proto"
	types "github.com/netauth/protocol"
)
var (
	lb hclog.Logger
)
func New(backend string) (*DB, error) {
	kv, err := NewKV(backend, log())
	if err != nil {
		return nil, err
	}
	idx := NewIndex(log())
	x := &DB{
		log:   log(),
		Index: idx,
		kv:    kv,
		cbs:   make(map[string]Callback),
	}
	kv.SetEventFunc(x.FireEvent)
	x.Index.ConfigureCallback(x.LoadEntity, x.LoadGroup)
	x.RegisterCallback("BleveSearch", x.Index.IndexCallback)
	return x, nil
}
func (db *DB) DiscoverEntityIDs() ([]string, error) {
	return db.kv.Keys("/entities/*")
}
func (db *DB) LoadEntity(ID string) (*types.Entity, error) {
	b, err := db.kv.Get(path.Join("/entities", ID))
	if err == ErrNoValue {
		return nil, ErrUnknownEntity
	}
	if err != nil {
		db.log.Debug("Error loading entity from KV store", "error", err, "ID", ID)
		return nil, ErrInternalError
	}
	e := &types.Entity{}
	if err := proto.Unmarshal(b, e); err != nil {
		db.log.Warn("Error unmarshaling entity", "error", err)
		return nil, ErrInternalError
	}
	return e, nil
}
func (db *DB) SaveEntity(e *types.Entity) error {
	b, _ := proto.Marshal(e)
	if err := db.kv.Put(path.Join("/entities", e.GetID()), b); err != nil {
		db.log.Warn("Error storing entity", "error", err)
		return ErrInternalError
	}
	return nil
}