-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstructorModel.js
57 lines (54 loc) · 1.2 KB
/
InstructorModel.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
import mongoose from 'mongoose';
const instructorSchema = new mongoose.Schema(
{
name: {
type: String,
required: [true, 'Please tell us your name!'],
},
email: {
type: String,
required: [true, 'Please provide your email'],
unique: true,
},
photo: {
type: String,
default: 'default.jpg',
},
description: {
type: String,
required: [true, 'Please provide your description'],
},
specialization: {
type: String,
required: [true, 'Please provide your specialization'],
},
courses: [
{
type: mongoose.Schema.ObjectId,
ref: 'Course',
},
],
rating: {
type: Number,
default: 4.5,
min: [1, 'Rating must be above 1.0'],
max: [5, 'Rating must be below 5.0'],
},
status: {
type: String,
default: 'active',
enum: ['active', 'inactive'],
},
experience: {
type: Number,
required: [true, 'Please provide your experience'],
},
},
{
timestamps: true,
toJSON: { virtuals: true },
toObject: { virtuals: true },
},
);
const Instructor = mongoose.model('Instructor', instructorSchema);
export default Instructor;