Commits

Luke Plant committed 4a344e4

Small refactor

  • Participants
  • Parent commits 3717fda

Comments (0)

Files changed (1)

File src/Blog/Model.hs

   return p
 
 deletePost cn uid = do
-  DB.doDelete cn "post_categories" "WHERE post_id = ?" [toSql uid]
+  deletePostCategoriesForPost cn uid
   DB.doDelete cn "posts" "WHERE id = ?" [toSql uid]
 
 -- category table
         "WHERE id = ?" [ toSql $ Ct.uid c]
 
 deleteCategory cn uid = do
-  DB.doDelete cn "post_categories" "WHERE category_id = ?" [toSql uid]
+  deletePostCategoriesForCat cn uid
   DB.doDelete cn "categories" "WHERE id = ?" [toSql uid]
 
 -- post_categories tables
                              [toSql $ fst pc,
                               toSql $ snd pc];
                              return pc; }
+
+deletePostCategoriesForCat cn catId =
+  DB.doDelete cn "post_categories" "WHERE category_id = ?" [toSql catId]
+
+deletePostCategoriesForPost cn postId =
+  DB.doDelete cn "post_categories" "WHERE post_id = ?" [toSql postId]
+
 setPostCategories cn postId catIds = do
-  DB.doDelete cn "post_categories" "WHERE post_id = ?" [toSql postId]
+  deletePostCategoriesForPost cn postId
   mapM_ (\c -> addPostCategory cn (postId, c)) catIds