-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathuserModel.js
103 lines (101 loc) · 2.1 KB
/
userModel.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
const mongoose = require("mongoose");
const { allIITGHostelsGC, NotificationCategories, defaultNotifCategoriesMap, allIITGHostels } = require("../helpers/constants");
const NotifPrefSchema = new mongoose.Schema({
"lost": {
type: Boolean,
default: true,
required: true,
},
"found": {
type: Boolean,
default: true,
required: true
},
"buy": {
type: Boolean,
default: true,
required: true
},
"sell": {
type: Boolean,
default: true,
required: true
},
"cabSharing": {
type: Boolean,
default: true,
required: true
},
"announcement": {
type: Boolean,
default: true,
required: true
}
});
const userSchema = new mongoose.Schema({
name: {
type: String,
required: true
},
outlookEmail: {
type: String,
required: true
},
altEmail: {
type: String,
},
rollNo: {
type: String,
required: true
},
dob: {
type: Date,
},
gender: {
type: String,
enum: ["Male", "Female", "Others"]
},
hostel: {
type: String,
enum: allIITGHostels
},
roomNo: {
type: String,
maxLength: 10,
},
homeAddress: {
type: String,
maxLength: 400,
},
phoneNumber: {
type: Number,
min: [1000000000, "Invalid mobile number."],
max: [9999999999, "Invalid mobile number."],
},
emergencyPhoneNumber: {
type: Number,
min: [1000000000, "Invalid mobile number."],
max: [9999999999, "Invalid mobile number."]
},
linkedin: {
type: String,
maxLength: 100
},
blocked: {
type: Boolean,
default: false
},
notifPref: {
type: NotifPrefSchema,
default: defaultNotifCategoriesMap
},
cycleReg: {
type: String,
maxLength: 20
},
subscribedMess: {
type: String,
enum: allIITGHostels
}
});
module.exports = mongoose.model("onestopUser", userSchema);