-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodels.js
34 lines (28 loc) · 962 Bytes
/
models.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const mongoose = require("mongoose");
const { Schema } = mongoose;
const date = new Date();
const ReplySchema = new Schema({
text: { type: String },
delete_password: { type: String },
created_on: { type: Date, default: date },
bumped_on: { type: Date, default: date },
reported: { type: Boolean, default: false },
});
const Reply = mongoose.model("Reply", ReplySchema);
const ThreadSchema = new Schema({
text: { type: String },
delete_password: { type: String },
reported: { type: Boolean, default: false },
created_on: { type: Date, default: date },
bumped_on: { type: Date, default: date },
replies: { type: [ReplySchema] },
});
const Thread = mongoose.model("Thread", ThreadSchema);
const BoardSchema = new Schema({
name: { type: String },
threads: { type: [ThreadSchema] },
});
const Board = mongoose.model("Board", BoardSchema);
exports.Board = Board;
exports.Thread = Thread;
exports.Reply = Reply;