This commit is contained in:
2025-11-21 16:19:47 +03:00
parent 2480f7c376
commit fa860921da
13 changed files with 1020 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
const mongoose = require('../../../utils/mongoose');
const crypto = require('crypto');
const expertSchema = new mongoose.Schema({
fullName: {
type: String,
required: true
},
token: {
type: String,
unique: true
},
qrCodeUrl: {
type: String,
default: ''
},
createdAt: {
type: Date,
default: Date.now
},
updatedAt: {
type: Date,
default: Date.now
}
}, {
timestamps: true
});
// Generate unique token before saving
expertSchema.pre('save', function(next) {
if (!this.token) {
this.token = crypto.randomBytes(16).toString('hex');
}
next();
});
module.exports = mongoose.model('Expert', expertSchema);