Skip to content
Permalink
Browse files

posts: select all from db

  • Loading branch information...
3v0k4 committed Jul 20, 2019
1 parent 5253688 commit 7a0735fc2fe8ce3420773cd2bd8a41dde6d74fa3
Showing with 7 additions and 7 deletions.
  1. +3 −0 src/Handler/Posts.hs
  2. +4 −7 templates/posts.hamlet
@@ -4,6 +4,7 @@
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}

module Handler.Posts where

@@ -17,12 +18,14 @@ postForm =
getPostsR :: Handler Html
getPostsR = do
(widget, enctype) <- generateFormPost postForm
allPosts :: [Entity Post] <- runDB $ selectList [] []
emptyLayout $ do
$(widgetFile "posts")

postPostsR :: Handler Html
postPostsR = do
((result, widget), enctype) <- runFormPost postForm
allPosts :: [Entity Post] <- runDB $ selectList [] []
case result of
FormSuccess _ ->
redirect PostsR
@@ -9,10 +9,7 @@
<button>Post

<ul>
<li>
<h2>Title 1
<p>Text 1

<li>
<h2>Title 2
<p>Text 2
$forall post <- allPosts
<li>
<h2> #{postTitle $ entityVal post}
<p> #{postText $ entityVal post}

0 comments on commit 7a0735f

Please sign in to comment.
You can’t perform that action at this time.