Listing books

This commit is contained in:
2018-08-05 23:42:37 +03:00
parent f8f35007bf
commit 46c728c3c8
6 changed files with 90 additions and 4 deletions

View File

@ -3,6 +3,7 @@
module Database.Channel
( userChannels
, insertChannel
, booksChannels
, Channel(..) )
where
@ -32,3 +33,13 @@ insertChannel username channel = do
userId :*: _ :*: user :*: _ <- select (gen users)
restrict (user .== literal username)
return userId
booksChannels :: (MonadMask m, MonadIO m) => HashDigest -> SeldaT m [Channel]
booksChannels contentHash = fromRels <$> query q
where
q = do
channelId :*: contentHash' <- select (gen bookChannels)
ch@(channelId' :*: _) <- select (gen channels)
restrict (channelId .== channelId')
restrict (contentHash' .== literal contentHash)
return ch