on master help sign in
Document values
fce7213Ollie Charles
src/Rel8/Query/Values.hs+9
@@ -20,5 +20,14 @@ import Rel8.Table.Opaleye ( valuesspec )
20import Rel8.Schema.Context ( DB )
20import Rel8.Schema.Context ( DB )
21
21
22
22
23+-- | Construct a query that returns the given input list of rows. This is like
24+-- folding a list of 'return' statements under 'union', but uses the SQL
25+-- @VALUES@ expression for efficiency.
26+--
27+-- Typically @values@ will be used with 'lit':
28+--
29+-- >>> mapM_ Data.Text.IO.putStrLn =<< select c (values [ lit "Hello", lit "World!" ])
30+-- Hello
31+-- World!
23values :: (Table DB a, Foldable f) => f a -> Query a
32values :: (Table DB a, Foldable f) => f a -> Query a
24values = fromOpaleye . Opaleye.valuesExplicit valuesspec . toList
33values = fromOpaleye . Opaleye.valuesExplicit valuesspec . toList