Thanks Pavel for your quick response.
One drawback I could see here is about embedding Author info inside collection. So, as and when a user updates the profile pic, we have to update it in all of his blogs, comments and likes? Is there any way to handle this?
What about the below schema? Here, we are storing blog and comments in a single collection, with a field “type” to distinguish it. If it is a comment, then we will keep the blogId in it’s “parent_id” field. Then, we need to have separate collection for “Users”. And, of course, we need to run a second query to get the profile pic.
Any suggestions?
{
id: { type: String, },
type: { type: String, required: true, enum: ['post', 'comment'] },
post_uid: { type: String, required: true },
content: { type: String, required: false },
author_id: { type: Number, required: true },
timestamp: { type: Date, required: true },
vote_count: { type: Number, required: true },
comment_count: { type: Number, required: true },
parent_id: { type: String, required: false },
votes: [
{
vote_id: { type: String},
voted_user_id: { type: Number, required: true },
timestamp: { type: String, required: true },
},
],
})