From 18981a8525aa25c973d4177960c64acd572d1177 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 4 Apr 2024 10:30:47 -0400 Subject: [PATCH 1/3] CHE-57 Created forum model --- server/models/forumModel.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 server/models/forumModel.ts 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; From 542ca9ef6eb4d34594156e65cfb00d20af8edae8 Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 4 Apr 2024 10:41:39 -0400 Subject: [PATCH 2/3] CHE-57 Created thread model --- server/models/threadModel.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 server/models/threadModel.ts diff --git a/server/models/threadModel.ts b/server/models/threadModel.ts new file mode 100644 index 0000000..2c4925b --- /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 }, // Creator of the thread + forum: { type: mongoose.Schema.Types.ObjectId, ref: "Forum", required: true }, // Associated forum + 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; From c1fbe9179860c99c8c7fbb9175dd664e9f37ff9f Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 4 Apr 2024 10:57:13 -0400 Subject: [PATCH 3/3] CHE-57 Created post model --- server/models/postModel.ts | 17 +++++++++++++++++ server/models/threadModel.ts | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 server/models/postModel.ts 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 index 2c4925b..3e9c279 100644 --- a/server/models/threadModel.ts +++ b/server/models/threadModel.ts @@ -1,8 +1,8 @@ import mongoose from "mongoose"; const threadSchema = new mongoose.Schema({ - user: { type: mongoose.Schema.Types.ObjectId, ref: "User", required: true }, // Creator of the thread - forum: { type: mongoose.Schema.Types.ObjectId, ref: "Forum", required: true }, // Associated forum + 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 },