-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #61 from Code-Hammers/CHE-57/subtask/Create-Databa…
…se-Models [CHE-57] Create Database Models
- Loading branch information
Showing
3 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; |