summaryrefslogtreecommitdiff
path: root/system/db/content.go
diff options
context:
space:
mode:
authorSteve <nilslice@gmail.com>2016-10-13 13:02:27 -0700
committerGitHub <noreply@github.com>2016-10-13 13:02:27 -0700
commit9c8ed5c6a88901bf139bf9bb7b884b222c6053ce (patch)
treea4aef6a41f4777ae037656820edefb80da62c03a /system/db/content.go
parent7556e81dcf93c9f93c65aae46ceb871dd6f99812 (diff)
parent468d9fb3355bd7771af3592becb201b6e9b1e68b (diff)
Merge pull request #1 from bosssauce/ponzu-dev
[fundamental-feature] Delete Content
Diffstat (limited to 'system/db/content.go')
-rw-r--r--system/db/content.go18
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) {