first commit

This commit is contained in:
2026-04-11 14:08:27 +07:00
parent e86e5d2c46
commit 6b7655aa16
389 changed files with 5387 additions and 60861 deletions

88
models/degree.js Normal file
View File

@@ -0,0 +1,88 @@
const mongoose = require('mongoose');
const degreeSchema = new mongoose.Schema({
// Required fields
qualification_number: {
type: String,
required: true,
unique: true,
trim: true
},
student_name: {
type: String,
required: true,
trim: true
},
program_name: {
type: String,
required: true,
trim: true
},
type: {
type: String,
required: true,
enum: ['qualification', 'certification']
},
department: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Department',
required: true
},
level: {
type: mongoose.Schema.Types.ObjectId,
ref: 'Level',
required: true
},
issued_date: {
type: Date,
required: true
},
status: {
type: String,
enum: ['active', 'revoked'],
default: 'active'
},
// Optional fields
certification_number: {
type: String,
trim: true,
},
passport_number: {
type: String,
trim: true
},
address: {
type: String,
trim: true
},
topic_name: {
type: String,
trim: true
},
topic_short_desc: {
type: String,
trim: true
},
degree_image: {
type: String
},
certificate_image: {
type: String
}
}, {
timestamps: true
});
// Indexes
degreeSchema.index({ certification_number: 1 }, { unique: true, sparse: true });
// Pre-save hook: certification type requires certification_number
degreeSchema.pre('save', function (next) {
if (this.type === 'certification' && !this.certification_number) {
return next(new Error('certification_number is required for certification type'));
}
next();
});
module.exports = mongoose.model('Degree', degreeSchema);