Add current project files
This commit is contained in:
parent
250ecbe1e5
commit
34e4244d65
32 changed files with 6470 additions and 0 deletions
57
backend/models.js
Normal file
57
backend/models.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
const mongoose = require('mongoose');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
const userSchema = new mongoose.Schema({
|
||||
username: { type: String, required: true, unique: true },
|
||||
password: { type: String, required: true },
|
||||
});
|
||||
|
||||
userSchema.pre('save', async function(next) {
|
||||
if (this.isModified('password')) {
|
||||
this.password = await bcrypt.hash(this.password, 10);
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
userSchema.methods.comparePassword = function(candidatePassword) {
|
||||
return bcrypt.compare(candidatePassword, this.password);
|
||||
};
|
||||
|
||||
const User = mongoose.model('User', userSchema);
|
||||
|
||||
const projectSchema = new mongoose.Schema({
|
||||
title: String,
|
||||
description: String,
|
||||
images: [String],
|
||||
});
|
||||
|
||||
const educationSchema = new mongoose.Schema({
|
||||
degree: String,
|
||||
institution: String,
|
||||
startYear: Number,
|
||||
endYear: Number,
|
||||
});
|
||||
|
||||
const jobExperienceSchema = new mongoose.Schema({
|
||||
jobTitle: String,
|
||||
company: String,
|
||||
startYear: Number,
|
||||
endYear: Number,
|
||||
});
|
||||
|
||||
const resumeSchema = new mongoose.Schema({
|
||||
pdfURL: String,
|
||||
});
|
||||
|
||||
const socialSchema = new mongoose.Schema({
|
||||
platform: String,
|
||||
url: String,
|
||||
});
|
||||
|
||||
const Project = mongoose.model('Project', projectSchema);
|
||||
const Education = mongoose.model('Education', educationSchema);
|
||||
const JobExperience = mongoose.model('JobExperience', jobExperienceSchema);
|
||||
const Resume = mongoose.model('Resume', resumeSchema);
|
||||
const Social = mongoose.model('Social', socialSchema);
|
||||
|
||||
module.exports = { User, Project, Education, JobExperience, Resume, Social };
|
||||
Loading…
Add table
Add a link
Reference in a new issue