You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
1.2 KiB
JavaScript
79 lines
1.2 KiB
JavaScript
1 year ago
|
// Solution from the given activity
|
||
|
|
||
|
// importing model
|
||
|
// Modules and Dependencies
|
||
|
const mongoose = require("mongoose");
|
||
|
|
||
|
// Schema/Blueprint
|
||
|
const userSchema = new mongoose.Schema({
|
||
|
|
||
|
firstName: {
|
||
|
type: String,
|
||
|
required: [true, "First name is required"]
|
||
|
},
|
||
|
|
||
|
lastName: {
|
||
|
type: String,
|
||
|
required: [true, "Last name is required"]
|
||
|
},
|
||
|
|
||
|
email: {
|
||
|
type: String,
|
||
|
required: [true, "Email is required"]
|
||
|
},
|
||
|
|
||
|
password: {
|
||
|
type: String,
|
||
|
required: [true, "Password is required"]
|
||
|
},
|
||
|
|
||
|
isAdmin: {
|
||
|
type: Boolean,
|
||
|
default: false
|
||
|
},
|
||
|
|
||
|
mobileNo: {
|
||
|
type: String,
|
||
|
required: [true, "Mobile No is required"]
|
||
|
},
|
||
|
|
||
|
enrollments: [
|
||
|
{
|
||
|
courseId: {
|
||
|
type: String,
|
||
|
required: [true, "Course ID is required"]
|
||
|
},
|
||
|
|
||
|
courseName: {
|
||
|
type: String,
|
||
|
required: [true, "Course Name is required"]
|
||
|
},
|
||
|
|
||
|
courseDescription: {
|
||
|
type: String,
|
||
|
required: [true, "Course Description is required"]
|
||
|
},
|
||
|
|
||
|
coursePrice: {
|
||
|
type: Number,
|
||
|
required: [true, "Course Price is required"]
|
||
|
},
|
||
|
|
||
|
|
||
|
|
||
|
enrolledOn: {
|
||
|
type: Date,
|
||
|
default: new Date()
|
||
|
},
|
||
|
|
||
|
status: {
|
||
|
type: String,
|
||
|
default: "Enrolled"
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
|
||
|
});
|
||
|
|
||
|
// Model
|
||
|
module.exports = mongoose.model("User", userSchema);
|