-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathCourse.js
72 lines (67 loc) · 1.27 KB
/
Course.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
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
import mongoose from "mongoose";
const schema = new mongoose.Schema({
title: {
type: String,
required: [true, "Please enter Course title"],
minLength: [4, "title must be atleast 4 chars"],
maxLength: [80, "title must be atmax 80 chars"],
},
description: {
type: String,
required: [true, "Please enter Course description"],
minLength: [20, "description must be atleast 20 chars"],
},
lectures: [
{
title: {
type: String,
required: true,
},
description: {
type: String,
required: true,
},
video: {
public_id: {
type: String,
//required: true,
},
url: {
type: String,
//required: true,
},
},
},
],
poster: {
public_id: {
type: String,
required: true,
},
url: {
type: String,
required: true,
},
},
views: {
type: Number,
default: 0,
},
numVideos: {
type: Number,
default: 0,
},
category: {
type: String,
required: true,
},
createdBy: {
type: String,
required: [true, "Enter course creator name"],
},
createdAt: {
type: Date,
default: Date.now()
},
});
export const Course = mongoose.model("Course", schema);