In Node.js, the express framework-based database uses MongoDB.
However, it was not as easy as I thought how to implement the comments and subcomments.
Can I get advice from people who have implemented or experienced these features?
node.js back-end javascript mongodb
Your question is about one-to-many relationship.
One post can have multiple comments and each comment can have multiple comments. However, one comment does not have multiple posts, and likewise, one comment cannot have multiple comments and sub-comments. So if you refer to the official document or these articles, you can roughly organize them like this.
/* Strategy */
{
_id: 102,
comment: "You know..."
/* Skipping */
subcomments: [103, 105, 111, 156] /* comments processed as subcomments._ids */
},
{
_id: 103,
comment: "ㄴLOL",
/* Skipping */
subcomments: null /* If there are no subcomments or deleted, remove the key or null */
},
/* Skipping */
581 PHP ssh2_scp_send fails to send files as intended
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
578 Understanding How to Configure Google API Key
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.