-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcourseModel.ts
More file actions
117 lines (113 loc) · 3.16 KB
/
Copy pathcourseModel.ts
File metadata and controls
117 lines (113 loc) · 3.16 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import mongoose, { Schema, Document, Model } from "mongoose";
import { IRating } from "./ratingModel";
import { IHandout } from "./handoutModel";
import { IUser } from "./userModel";
import { ISpeaker } from "./speakerModel";
export interface ICourse extends Document {
handouts: (mongoose.Types.ObjectId | IHandout)[];
ratings: (mongoose.Types.ObjectId | IRating)[];
className: string;
discussion: string;
isLive: boolean;
categories: string[];
creditNumber: number;
courseDescription: string;
thumbnailPath: string;
bannerPath: string;
cost: number;
instructorName: string;
instructorDescription: string;
instructorRole: string;
students: (mongoose.Types.ObjectId | IUser)[]; //for the users
managers: (mongoose.Types.ObjectId | IUser)[];
speakers: (mongoose.Types.ObjectId | ISpeaker)[];
regStart: Date;
regEnd: Date;
//Virtual Training - Live Meeting, In-Person Training, Virtual Training - On Demand, Virtual Training - Live Webinar
productType:
| "Virtual Training - Live Meeting"
| "In-Person Training"
| "Virtual Training - On Demand"
| "Virtual Training - Live Webinar";
productInfo: string;
shortUrl: string;
draft: boolean;
registrationLimit: number;
waitlist: { user: mongoose.Types.ObjectId | IUser; joinedAt: Date }[];
}
const CourseSchema: Schema = new Schema(
{
handouts: [
{
type: Schema.Types.ObjectId,
ref: "Handout",
},
],
ratings: [
{
type: Schema.Types.ObjectId,
ref: "Rating",
},
],
className: { type: String, required: false },
discussion: { type: String, required: false },
categories: [{ type: String, required: false }],
creditNumber: { type: Number, required: false },
courseDescription: { type: String, required: false },
thumbnailPath: { type: String, required: false },
bannerPath: { type: String, required: false },
cost: { type: Number, required: false },
instructorDescription: { type: String, required: false },
instructorRole: { type: String, required: false },
time: { type: Date, required: false },
instructorName: { type: String, required: false },
isInPerson: { type: Boolean, required: false },
students: [
{
type: Schema.Types.ObjectId,
ref: "User",
},
],
managers: [
{
type: Schema.Types.ObjectId,
ref: "User",
},
],
speakers: [
{
type: Schema.Types.ObjectId,
ref: "Speaker",
},
],
regStart: { type: Date, required: false },
regEnd: { type: Date, required: false },
productType: {
type: String,
required: false,
enum: [
"Virtual Training - Live Meeting",
"In-Person Training",
"Virtual Training - On Demand",
"Virtual Training - Live Webinar",
"",
],
},
productInfo: { type: String, required: false },
shortUrl: { type: String, required: false },
draft: { type: Boolean, required: true, default: true },
registrationLimit: { type: Number, required: false, default: 0 },
waitlist: [
{
user: { type: Schema.Types.ObjectId, ref: "User", required: true },
joinedAt: { type: Date, required: true, default: Date.now },
_id: false,
},
],
},
{
timestamps: true,
}
);
const Course: Model<ICourse> = mongoose.model<ICourse>("Course", CourseSchema);
export default Course;