5 ms·
Rel8 allows you to return trees of data: https://hackage.haskell.org/package/rel8-1.3.0.0/docs/Rel8.html#v:listAgg https://hackage.haskell.org/package/rel8-1.3
by tome 5y ago
Rel8 allows you to return trees of data:
https://hackage.haskell.org/package/rel8-1.3.0.0/docs/Rel8.html#v:listAgg https://hackage.haskell.org/package/rel8-1.3.0.0/docs/Rel8.h...
- jeremyjh 5y agoThat's awesome, thanks for linking it to me. I don't think I have seen this library before, looks like its fairly new. I have to admit from the signature I can't tell if I can nest these arbitrarily deep, it looks like I can?
- ParetoOptimal 5y agoRel8 is pretty new, but it's built on top of opaleye which is much older.
- tome 5y agoArbitrary nesting is supported module Main where import Rel8 import Data.Int import Hasql.Statement import Hasql.Session import Hasql.Connection import Database.Postgres.Temp main = Database.Postgres.Temp.with $ \db -> do Right conn <- acquire (toConnectionString db) flip run conn $ statement () $ select $ do q1 <- many $ do r1 <- many (values [1 , 2 :: Expr Int16]) r2 <- many (values [3 , 4 :: Expr Int16]) values [(litExpr "one", r1), (litExpr "two", r2)] q2 <- many $ do r1 <- many (values [10 , 20 :: Expr Int16]) r2 <- many (values [30 , 40 :: Expr Int16]) values [(litExpr "ten", r1), (litExpr "twenty", r2)] values [(litExpr "X", q1), (litExpr "Y", q2)] > main Right (Right [("X",[("one",[1,2]),("two",[3,4])]),("Y",[("ten",[10,20]),("twenty",[30,40])])])
- tome 5y agoHaving said that, Postgres supports JSON fine, and Opaleye and Rel8 support Postgres's JSON fine, so you can just use that if you want arbitrarily structured and nested stuff.