bitemyapp / bitemyapp/esqueleto
aggregate entities
- Dominant language
- Haskell
- Stars
- 399
- Forks
- 107
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 1
Description
currently `arrayAgg` from `Database.Esqueleto.PostgreSQL` allows to aggregate `Value`s.
It would be nice if it was possible also to aggregate entities.
For example, consider a 1:n relation between tables `foo` and `bar`. IT would be nice to write
```
data Baz = Baz
{ bazFoo :: Entity Foo
, bazBars :: [Entity Bar]
}
$(deriveEsqueletoRecord ''Baz)
query :: FooId -> SqlPersistT m [Baz]
query fooId =
select $ do
foo :& bar <-
from $
table @Foo
`leftJoin` table @Bar
`on` (\(foo :& bar) -> just foo.id ==. bar.foo)
where_ $ foo.id = val fooId
groupBy foo.id
pure $
SqlBaz
{ bazFoo = foo
, bazBars = arrayAgg bar
}
```
or something analogous
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.