Hi @Roi_Bar ,
In terms of upvotes I am more of a fan for keeping data that is queried and upfated together in the same document.
What is possible is for each post that is being upvoted keep an array of user ids that upvoted on it and the total number of votes/downvotes
votes : { n : 50,
users : [ "id1", "id2" .... "Id50" ],
downVotes : ...
Traversing this array on the client side when building the Ui should not be problematic and will be fast to indicate a full or empty like for the connected user.
For the replies on a specific inner answer/post, the nature of those would usually be of a lower magnetitude compared to the amount of messages on the main thread. Therefore I assume the 100-200 inner comments can live in the embedded array. Moreover the nature of showing those heirarchy is usually paginated. So keeping the top comments embedded and any click on “load more” can go to this outlier collection which holds the extra long comment threads …
For mongoose I have not much to share as I rather not use it exactly because of the schema type limitations, it prevents me for using MongoDB polymorphism which is one of the strongest points of MongoDB. Documents does not have to be the same, and fhey can only share a common attribute for logical queries … This is a classic example where all content will probably hold a post id . The documents can then have different fields for different type of posts. Your UI should be Smart enough to get a post and based on its structure for it correctly. Any validation can be done on the buisness logic of the application backend …
Hope that helps
Pavel
1 Like