-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdoctor.js
46 lines (42 loc) · 945 Bytes
/
doctor.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var mongoose = require('mongoose');
const bcrypt = require('bcrypt');
//Define a schema
var Schema = mongoose.Schema;
var Doctor = new Schema({
_id: {
type:Number,
min: [6, 'Too few characters'],
required:[true, "Need an ID!"],
},
email:{
type:String,
required:[true,"Need an Email!"],
},
username:{
type:String,
required:[true,"Need an Username!"],
},
hashPassword: {
type:String,
required:[true,"Need an Password!"],
min:[7, "password must be more secure"],
},
firstname:{
type:String,
required:[true, "Need an First Name!"],
},
lastname:{
type:String,
required:[true,"Need an Last Name!"],
},
speciality: {
type:String,
required:[true,"Need an Speciality!"],
},
patientsIDs:[Number],
appointment: [String],
});
Doctor.methods.comparePasswords = (password, hashPassword) => {
return bcrypt.compareSync(password, hashPassword);
}
module.exports = mongoose.model('Doctor', Doctor );