-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.js
More file actions
78 lines (74 loc) · 1.57 KB
/
Copy pathUser.js
File metadata and controls
78 lines (74 loc) · 1.57 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
// Import the Mongoose library
const mongoose = require("mongoose");
// Define the user schema using the Mongoose Schema constructor
const userSchema = new mongoose.Schema(
{
// Define the name field with type String, required, and trimmed
firstName: {
type: String,
required: true,
trim: true,
},
lastName: {
type: String,
required: true,
trim: true,
},
// Define the email field with type String, required, and trimmed
email: {
type: String,
required: true,
trim: true,
},
// Define the password field with type String and required
password: {
type: String,
required: true,
},
// Define the role field with type String and enum values of "Admin", "Student", or "Visitor"
accountType: {
type: String,
enum: ["Admin", "Student", "Instructor"],
required: true,
},
active: {
type: Boolean,
default: true,
},
approved: {
type: Boolean,
default: true,
},
additionalDetails: {
type: mongoose.Schema.Types.ObjectId,
required: true,
ref: "Profile",
},
courses: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "Course",
},
],
token: {
type: String,
},
resetPasswordExpires: {
type: Date,
},
image: {
type: String,
required: true,
},
courseProgress: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "courseProgress",
},
],
// Add timestamps for when the document is created and last modified
},
{ timestamps: true }
);
// Export the Mongoose model for the user schema, using the name "user"
module.exports = mongoose.model("user", userSchema);