on eb180fa help sign in
rel8/src/Rel8/Query/Each.hs
36 lines 901 B history raw
1{-# language FlexibleContexts #-}
3module Rel8.Query.Each
4 ( each
5 )
6where
8-- base
9import Prelude
11-- opaleye
12import qualified Opaleye.Table as Opaleye
14-- rel8
15import Rel8.Query ( Query )
16import Rel8.Query.Opaleye ( fromOpaleye )
17import Rel8.Schema.Table ( TableSchema )
18import Rel8.Table ( fromColumns, toColumns )
19import Rel8.Table.Opaleye ( table, unpackspec )
20import Rel8.Table.Recontextualize ( Selects )
23-- | Select each row from a table definition. This is equivalent to @FROM
24-- table@.
25--
26-- >>> mapM_ print =<< select c (each projectSchema)
27-- Project {projectAuthorId = 1, projectName = "rel8"}
28-- Project {projectAuthorId = 2, projectName = "aeson"}
29-- Project {projectAuthorId = 2, projectName = "text"}
30each :: Selects names exprs => TableSchema names -> Query exprs
31each =
32 fmap fromColumns .
33 fromOpaleye .
34 Opaleye.selectTableExplicit unpackspec .
35 table .
36 fmap toColumns