diff --git a/server/models/forumModel.ts b/server/models/forumModel.ts new file mode 100644 index 0000000..4c69b34 --- /dev/null +++ b/server/models/forumModel.ts @@ -0,0 +1,12 @@ +import mongoose from "mongoose"; + +const forumSchema = new mongoose.Schema({ + title: { type: String, required: true }, + description: { type: String, required: true }, + createdAt: { type: Date, default: Date.now }, + updatedAt: { type: Date, default: Date.now }, +}); + +const Forum = mongoose.model("Forum", forumSchema); + +export default Forum; diff --git a/server/models/postModel.ts b/server/models/postModel.ts new file mode 100644 index 0000000..a8b6598 --- /dev/null +++ b/server/models/postModel.ts @@ -0,0 +1,17 @@ +import mongoose from "mongoose"; + +const postSchema = new mongoose.Schema({ + thread: { + type: mongoose.Schema.Types.ObjectId, + ref: "Thread", + required: true, + }, + user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true }, + content: { type: String, required: true }, + createdAt: { type: Date, default: Date.now }, + updatedAt: { type: Date, default: Date.now }, +}); + +const Post = mongoose.model("Post", postSchema); + +export default Post; diff --git a/server/models/threadModel.ts b/server/models/threadModel.ts new file mode 100644 index 0000000..3e9c279 --- /dev/null +++ b/server/models/threadModel.ts @@ -0,0 +1,14 @@ +import mongoose from "mongoose"; + +const threadSchema = new mongoose.Schema({ + user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true }, + forum: { type: mongoose.Schema.Types.ObjectId, ref: "Forum", required: true }, + title: { type: String, required: true }, + content: { type: String, required: true }, + createdAt: { type: Date, default: Date.now }, + updatedAt: { type: Date, default: Date.now }, +}); + +const Thread = mongoose.model("Thread", threadSchema); + +export default Thread;