I have an existing comment system and to keep it short, comments and replies are in a reusable element and “this url” is stored on the comment table so the site knows which comments are displayed on which page. Works great (except for some dumb thing I did by not stripping out URL params…)
I want to expand comments to other “things” in my app, not just pages. I was thinking of keeping the comments data thing…
Data thing: comments
comment (text)
created by (user)
liked by (list of users)
page (‘this url’ when saved)
category (category thing)
rating
replies (list of comments)
… and then adding comments (list of comments) to any data thing I want people to comment on. Here’s one example: I have a thing called “light bulb moments” where people add a tweet-sized comment about what they learned in one of many courses they can take:
Data thing: ‘light bulb moments’ LBM
quote (text)
event (event thing)
liked by (list of users)
created by (user)
comments (list of comments…NEW FIELD)
I display these LBM’s throughout the site and want other course attendees to be able to comment, ask questions etc.
I was thinking of just adding a comments (list of comments) field to the LBM thing. Then I’d basically repeat the same pattern on all my other ‘things’
I think this is probably the cleanest way to do it so I can re-use the comments thing on anything, and use the same backend workflow everywhere. I can use the comment category and other filtering options to show comments anywhere. I don’t expect more than a handful of comments on any thing and maybe a few hundred total comments everything per year, given existing trends.
That would be a good way if you don’t expect thousands of comments in a thing; just a list of Comments in a Thing’s field.
Alternatively, you can have a text field in your Comment that stores the Unique ID of the whatever Thing it’s attached to. You just need to use “Unique ID = Thing Unique ID” when searching for comments.
To make things easier for editing, i created a reusable element for my “chatbox” so i only need to edit once instead of multiple times in different pages.
Good idea using the unique ID. I wonder if ‘do search for’ is more of a performance hit than a list of items in a ‘thing’. For my case, I think either works given it won’t be an insane number of comments.
I have a reusable comment and comment reply element too. It needs some simplification though!
I don’t a full understanding of your app’s architecture, but unless you have a crazy number of things you want to comment on, I would rather create a comment entity with a relation per thing you can comment on. It seems safer to search, edit etc. Adding them in a list to the the thing commented on makes it leaner but I’d be worried I don’t have good searchability. I am most probably be wrong, just my bubble sense tickling.
I wouldn’t say it’s a crazy amount, maybe 10 to 15. I think this would make searching easier because I’m only searching one thing. The ‘comment category’ field on the ‘comment thing’ allows me to filter. Plus, these comments are ‘point in time’ type of comments. Example: someone introduces themself and others like and comment on that activity. Or they post a problem, or AHA! moment from my courses and others chime in.
I’m going to try it on two of my most trafficked ‘things’ and see how it goes.