Reputation: 385
I use SQLite with persistent in Haskell.
I have a list of keys i.e. [PostId]
.
Now I want to get all entries
[Desc PostCrtDate, OffsetBy from, LimitTo (to - from + 1)]
.
Is there an alternative to selectList
but with a list of keys instead of or in addition to the "normal" conditions of a SQL query?
It seems horribly inefficient to use mapM get keyList
and then do sorting/offsetting/limiting, especially with a big database.
I am open to using esqueleto if necessary but I would rather not introduce another dependency.
Thanks!
Upvotes: 2
Views: 68
Reputation: 31355
I'm on a mobile right now and therefore may get the syntax wrong, but it's something like:
selectWhere [PostId <-. IdList] []
That operator is the "in" operator, checking if a value is in a list.
Note that this will not give any errors if some of the keys are not found, you'd need to check for that manually.
Upvotes: 3