diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-13 12:45:33 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-13 12:45:33 -0700 |
commit | 8d569ebc74b932fab0e1a725febddf92d43d2892 (patch) | |
tree | c5067e7fb74dbb9317ab4e12748b28044a9945e2 /system/db/content.go | |
parent | 4dceec07d9f34018f70b15f795e4af27ff753dc3 (diff) |
adding admin server handler for deleting content
Diffstat (limited to 'system/db/content.go')
-rw-r--r-- | system/db/content.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/system/db/content.go b/system/db/content.go index d637085..1e5b95a 100644 --- a/system/db/content.go +++ b/system/db/content.go @@ -137,6 +137,24 @@ func postToJSON(ns string, data url.Values) ([]byte, error) { return j, nil } +// DeleteContent removes an item from the database. Deleting a non-existent item +// will return a nil error. +func DeleteContent(target string) error { + t := strings.Split(target, ":") + ns, id := t[0], t[1] + + err := store.Update(func(tx *bolt.Tx) error { + tx.Bucket([]byte(ns)).Delete([]byte(id)) + return nil + }) + + if err != nil { + return err + } + + return nil +} + // Content retrives one item from the database. Non-existent values will return an empty []byte // The `target` argument is a string made up of namespace:id (string:int) func Content(target string) ([]byte, error) { |