about summary refs log tree commit diff
path: root/src/BlogDB.hs
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@gmail.com>2015-11-24T13·07+0100
committerVincent Ambo <tazjin@gmail.com>2015-11-24T13·07+0100
commit599d7659037477bb080a10f9027a39a4203c8ec8 (patch)
tree0b22226578151760cff9348623812efee139b052 /src/BlogDB.hs
parent94788f1f92b0d4d3733e044b015b72c0857d02cd (diff)
[blog] Add a deleteEntry function, only for CLI
Diffstat (limited to 'src/BlogDB.hs')
-rw-r--r--src/BlogDB.hs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/BlogDB.hs b/src/BlogDB.hs
index 52e4e80c397a..bc9c24393302 100644
--- a/src/BlogDB.hs
+++ b/src/BlogDB.hs
@@ -130,9 +130,15 @@ insertEntry e =
 updateEntry :: Entry -> Update Blog Entry
 updateEntry e =
     do b@Blog{..} <- get
-       put $ b { blogEntries = IxSet.updateIx (entryId e) e blogEntries}
+       put $ b { blogEntries = IxSet.updateIx (entryId e) e blogEntries }
        return e
 
+deleteEntry :: EntryId -> Update Blog EntryId
+deleteEntry entry =
+    do b@Blog{..} <- get
+       put $ b { blogEntries = IxSet.deleteIx entry blogEntries }
+       return entry
+
 getEntry :: EntryId -> Query Blog (Maybe Entry)
 getEntry eId =
     do Blog{..} <- ask
@@ -187,6 +193,7 @@ hashString = B64.encode .  SHA.hash . B.pack
 $(makeAcidic ''Blog
     [ 'insertEntry
     , 'updateEntry
+    , 'deleteEntry
     , 'getEntry
     , 'latestEntries
     , 'addSession