IHP 1.3 is out now!

Is there a good way to do nested/threaded comments in IHP?

Lillo PRO

Has anyone done nested comments in IHP in a clean-ish way yet?

I get the feeling that comment_id / parent_id inside the comments table is not a a good idea, but would be nice if I could just do that :)

I'm a bit skeptical to nested sets, but seems like the most popular answer on stack overflow

Fritz Feger PRO
Hi Lillo, I'm at a similar place, trying to build something like an outliner. The parent_id is just what I did, and indentation works, but I'm stuck at sorting the blocks. I've been reading on and experimenting with Tree structures, ultimately looking at Data.Tree, but currently I haven't gotten to the point of how to make a Tree from an IHP auto-built type on a DB table with self-referential records.
Lillo PRO
Thank for the input! Good that parent_id works :) Sounds like I will try to solve this with parent_id and Elm/SPA tech so I do a fetch for subcomments for every visible comment. Possibly also a good usecase for DataSync :)
marc PRO

Having a parent_id is the way to go IMO :)

Manborough

I'm very new to Haskell, but if you're able to use JSON in your view this recursive CTE can give you a nice tree structure to work with.

https://gist.github.com/Manborough/669abb4c095fe092c564b73e9c4ed159

It's been a long time since I worked with it/understood exactly how it functions, but I have found it useful in the past.