Download models/Course.js from LordOdin721/edusphere-admin-portal: direct link, hf CLI and curl.
- Browser
- Download file 1.2 kB
-
https://huggingface.co/spaces/LordOdin721/edusphere-admin-portal/resolve/main/models/Course.js
- Command line
-
hf download hf://spaces/LordOdin721/edusphere-admin-portal/models/Course.js
-
curl -L -o Course.js https://huggingface.co/spaces/LordOdin721/edusphere-admin-portal/resolve/main/models/Course.js
1.2 kB
| const mongoose = require('mongoose'); | |
| const courseSchema = new mongoose.Schema({ | |
| title: { | |
| type: String, | |
| required: [true, 'Please add a course title'], | |
| trim: true | |
| }, | |
| description: { | |
| type: String, | |
| required: [true, 'Please add a description'] | |
| }, | |
| category: { | |
| type: String, | |
| required: [true, 'Please add a category'] | |
| }, | |
| duration: { | |
| type: Number, | |
| required: [true, 'Please add course duration in weeks'] | |
| }, | |
| instructor: { | |
| type: mongoose.Schema.ObjectId, | |
| ref: 'User', | |
| required: true | |
| }, | |
| price: { | |
| type: Number, | |
| required: [true, 'Please add a price'] | |
| }, | |
| image: { | |
| type: String, | |
| default: 'default-course.jpg' | |
| }, | |
| isFeatured: { | |
| type: Boolean, | |
| default: false | |
| }, | |
| status: { | |
| type: String, | |
| enum: ['draft', 'published', 'archived'], | |
| default: 'draft' | |
| }, | |
| createdAt: { | |
| type: Date, | |
| default: Date.now | |
| } | |
| }, { | |
| toJSON: { virtuals: true }, | |
| toObject: { virtuals: true } | |
| }); | |
| // Reverse populate with enrollments | |
| courseSchema.virtual('enrollments', { | |
| ref: 'Enrollment', | |
| localField: '_id', | |
| foreignField: 'course', | |
| justOne: false | |
| }); | |
| module.exports = mongoose.model('Course', courseSchema); |