Skip to content

Instantly share code, notes, and snippets.

@dariooddenino
Last active March 11, 2019 13:59
Show Gist options
  • Save dariooddenino/20f590317271e03e133127a1744c49f1 to your computer and use it in GitHub Desktop.
Save dariooddenino/20f590317271e03e133127a1744c49f1 to your computer and use it in GitHub Desktop.
-- first I want to select some elements to display in my table
select $ from $ \(foo `innerJoin` bar) -> do
on (foo ^. FooBar ==. bar ^. BarId)
where_ (foo ^. FooFoo ==. E.val True)
orderBy [asc (foo ^. FooId)]
offset (resultsPerPage * pageNum)
limit resultsPerPage
pure (foo, bar)
-- then I want to count the total to know how many pages are there
select $ from $ \(foo `innerJoin` bar) -> do
on (foo ^. FooBar ==. bar ^. BarId)
where_ (foo ^. FooFoo ==. E.val True)
pure countRows
-- they're identical except for the last lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment