Build a community forum with threads, replies, voting, user reputation, and moderation tools
Create a community forum platform where users can create discussion threads, reply to posts, vote on content, build reputation, and moderators can manage the community.
// Thread model
const threadSchema = {
title: String,
content: String,
authorId: ObjectId,
categoryId: ObjectId,
upvotes: Number,
downvotes: Number,
createdAt: Date
};
// Vote on thread
async function voteThread(threadId, userId, voteType) {
await db.votes.upsert({
threadId,
userId,
voteType
});
await updateThreadScore(threadId);
await updateUserReputation(userId, voteType);
}