📅 29 Jul 2025
View on Github ↗Built a fully working Like/Dislike system in DevFlow — inspired by how platforms like Twitter or Reddit manage user reactions in real time.
Feature | Status |
---|---|
👍 Like a post | ✅ Done |
👎 Dislike a post | ✅ Done |
🔁 Toggle reactions cleanly | ✅ Handled |
🧠 Distinguish between Question and Answer | ✅ Via targetType |
🔐 Protected endpoints with auth | ✅ Secured |
{
_id: ObjectId,
userId: ObjectId,
targetId: ObjectId, // Question or Answer ID
targetType: "question" | "answer",
reaction: "like" | "dislike",
createdAt: Date
}
✅ Single schema handles both Questions and Answers ✅ Easily filter and aggregate by type or target
$match
+ $group
to count reactions efficientlytargetId
and userId
for fast toggles & countstargetId
existence before saving$set
logicBuilding reactions wasn’t just about toggling a field. It taught me how apps scale this data for:
“Big features start with small schemas — but scale with smart design.”