threaded-comments

What is the best practice for fetching a tree of nodes from database for further rendering?

不打扰是莪最后的温柔 提交于 2019-12-03 07:50:57
问题 Let's say we have a table with user comments. First-level comments have a reference to an article they are attached to. Deeper-level comments do not have this reference by design but they have a reference to it's parent comment. For this database structure - what would be the most efficient way to fetch all comments for a given article and then render it in html format? (Let's assume that we have approx. 200 comments of first level and the deepiest level of 20) 回答1: I usually recommend a

What is the best practice for fetching a tree of nodes from database for further rendering?

非 Y 不嫁゛ 提交于 2019-12-02 21:20:00
Let's say we have a table with user comments. First-level comments have a reference to an article they are attached to. Deeper-level comments do not have this reference by design but they have a reference to it's parent comment. For this database structure - what would be the most efficient way to fetch all comments for a given article and then render it in html format? (Let's assume that we have approx. 200 comments of first level and the deepiest level of 20) Bill Karwin I usually recommend a design called Closure Table . See example in my answer to What is the most efficient/elegant way to

Reddit-style nested/threaded/indented comments for Rails?

情到浓时终转凉″ 提交于 2019-11-28 13:53:44
问题 I'm wondering if someone has already built a system for threaded comments (for lack of a better term) in Rails or if I need to build it myself. In case it's not clear, what I'm referring to is a comment system like Reddit's that automatically indents replies so that they appear like branches of a tree (preferably with voting just as Reddit does). If someone could point me to code that does this, it would be greatly appreciated. Or perhaps there is an open source project that includes this