@@ -42,16 +42,39 @@ import qualified Data.Text as Text
42import Data.Text.Encoding ( encodeUtf8 )
42import Data.Text.Encoding ( encodeUtf8 )
45+-- | The constituent parts of a @DELETE@ statement.
45type Delete :: Type -> Type
46type Delete :: Type -> Type
46data Delete a where
47data Delete a where
47 Delete :: Selects names exprs =>
48 Delete :: Selects names exprs =>
48 { from :: TableSchema names
49 { from :: TableSchema names
50+ -- ^ Which table to delete from.
49 , deleteWhere :: exprs -> Expr Bool
51 , deleteWhere :: exprs -> Expr Bool
52+ -- ^ Which rows should be selected for deletion.
50 , returning :: Returning names a
53 , returning :: Returning names a
54+ -- ^ What to return from the @DELETE@ statement.
52 -> Delete a
56 -> Delete a
59+-- | Run a @DELETE@ statement.
61+-- >>> mapM_ print =<< select c (each projectSchema)
62+-- Project {projectAuthorId = 1, projectName = "rel8"}
63+-- Project {projectAuthorId = 2, projectName = "aeson"}
64+-- Project {projectAuthorId = 2, projectName = "text"}
68+-- { from = projectSchema
69+-- , deleteWhere = \p -> projectName p ==. lit "rel8"
70+-- , returning = Projection projectName
75+-- >>> mapM_ print =<< select c (each projectSchema)
76+-- Project {projectAuthorId = 2, projectName = "aeson"}
77+-- Project {projectAuthorId = 2, projectName = "text"}
55delete :: Delete a -> Connection -> IO a
78delete :: Delete a -> Connection -> IO a
56delete Delete {from, deleteWhere, returning} =
79delete Delete {from, deleteWhere, returning} =
57 case returning of
80 case returning of