Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to selectList without any filter or select options in Persistent Haskell?

Tags:

haskell

yesod

Good day.

I'm learning Yesod a few weeks (I am pretty new to Haskell) by writing a little project.I used MongoDB as the DB and accessing it by persistent-mongoDB. When I want to run a query which have no any conditions or sorting stuff, e.g.

IN MONGODB SHELL
> db.comments.find();

I can not find a correct way at least in the Yesod Book.

I tried to write a identical as a workaround.

IN YESOD REPL
*Application> db $ selectList [CommentContent !=. ""] []

But it sucks...

The same issue in a transact-sql query. e.g.

IN YESOD REPL
*Application> db $ count [CommentContent !=. "" ]
like image 569
Wade Xing Avatar asked Mar 15 '23 16:03

Wade Xing


1 Answers

Write what type you want

myData :: [Entity YOUR_ENTITY_HERE] <- selectList [] []

(I used ScopedTypeVariables here but is not needed if type can be inferred in other way)

like image 166
josejuan Avatar answered Apr 12 '23 23:04

josejuan