Coelacanths / skillsource

0 stars 2 forks source link

Users should be able to reply to another user's comment in a thread #5

Closed michellelockett closed 6 years ago

michellelockett commented 6 years ago

how to use self-referencing foreign keys in Sequelize:

https://stackoverflow.com/questions/24747652/sequelize-self-references-has-many-relation

rainier-c commented 6 years ago

One way to make this easier is to have a comment's subcomments returned in a 'children' array. For instance:

{ createdAt: "2018-03-16T02:46:29.000Z", id: 1, text: "What a great class. Continue your studies at Hack Reactor!", updatedAt: "2018-03-16T02:46:29.000Z", user: {...}, userId: 1, children: [ {...}, {...} ] }

The only thing new in the above code block is the 'children' array at the end. It is an array that holds, as objects, any comments that are nested under the current comment. The format (and schema) of each child comment would be identical to a 'parent' comment.

michellelockett commented 6 years ago
screen shot 2018-03-17 at 10 02 31 am
rainier-c commented 6 years ago

The latest PR implements some simple rendering of threaded comments. In line with discussions, we've kept the max depth of subcomments at 1. Will mark this as closed once everyone has had a chance to test and approve.