-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathhacker.model.js
More file actions
168 lines (165 loc) Β· 4.42 KB
/
hacker.model.js
File metadata and controls
168 lines (165 loc) Β· 4.42 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
"use strict";
const Constants = require("../constants/general.constant");
const mongoose = require("mongoose");
//describes the data type
const HackerSchema = new mongoose.Schema({
//account id
accountId: {
type: mongoose.Schema.Types.ObjectId,
ref: "Account",
required: true
},
status: {
type: String,
enum: Constants.HACKER_STATUSES,
required: true,
default: "None"
},
application: {
general: {
school: {
type: String,
required: true
},
degree: {
type: String,
required: true
},
fieldOfStudy: [
{
type: String,
required: true
}
],
graduationYear: {
type: Number,
required: true
},
jobInterest: {
type: String,
enum: Constants.JOB_INTERESTS,
required: true,
default: "None"
},
URL: {
//gcloud bucket link
resume: {
type: String,
default: ""
},
github: {
type: String
},
dribbble: {
type: String
},
personal: {
type: String
},
linkedIn: {
type: String
},
other: {
type: String
}
}
},
shortAnswer: {
skills: [
{
type: String
}
],
//any miscelaneous comments that the user has
comments: {
type: String,
default: ""
},
//"Why do you want to come to our hackathon?"
question1: {
type: String,
default: "",
required: true
},
// "Some Q"
question2: {
type: String,
default: "",
required: true
}
},
other: {
ethnicity: {
type: [
{
type: String,
required: true
}
],
required: true
},
privacyPolicy: {
type: Boolean,
required: true
},
codeOfConduct: {
type: Boolean,
required: true
}
},
accommodation: {
impairments: {
type: String,
default: ""
},
barriers: {
type: String,
default: ""
},
shirtSize: {
type: String,
enum: Constants.SHIRT_SIZES,
required: true
},
travel: { type: Number, default: 0 }
},
team: {
type: mongoose.Schema.Types.ObjectId,
ref: "Team"
}
},
teamId: {
type: mongoose.Schema.Types.ObjectId,
ref: "Team"
}
});
HackerSchema.methods.toJSON = function() {
const hs = this.toObject();
delete hs.__v;
hs.id = hs._id;
delete hs._id;
return hs;
};
HackerSchema.methods.isApplicationComplete = function() {
const hs = this.toObject();
const portfolioDone = !!hs.application.general.URL.resume;
const jobInterestDone = !!hs.application.general.jobInterest;
const question1Done = !!hs.application.shortAnswer.question1;
const question2Done = !!hs.application.shortAnswer.question2;
return portfolioDone && jobInterestDone && question1Done && question2Done;
};
/**
* @param field the field which should be queried
* @returns {String} type of the field being queried
* @description return the type of the field(if it exists and is allowed to be searched on)
*/
HackerSchema.statics.searchableField = function(field) {
const schemaField = HackerSchema.path(field);
if (schemaField != undefined) {
return schemaField.instance;
} else {
return null;
}
};
//export the model
module.exports = mongoose.model("Hacker", HackerSchema);