-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplication.js
More file actions
84 lines (80 loc) · 2.11 KB
/
Application.js
File metadata and controls
84 lines (80 loc) · 2.11 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
const { application } = require("express");
const mongoose = require("mongoose");
let schema = new mongoose.Schema(
{
userId: {
type: mongoose.Schema.Types.ObjectId,
required: true,
ref: "JobApplicantInfo",
},
recruiterId: {
type: mongoose.Schema.Types.ObjectId,
required: true,
ref: "RecruiterInfo",
},
jobId: {
type: mongoose.Schema.Types.ObjectId,
required: true,
ref: "jobs",
},
status: {
type: String,
enum: [
"applied", // when a applicant is applied
"shortlisted", // when a applicant is shortlisted
"accepted", // when a applicant is accepted
"rejected", // when a applicant is rejected
"deleted", // when any job is deleted
"cancelled", // an application is cancelled by its author or when other application is accepted
"finished", // when job is over
],
default: "applied",
required: true,
},
dateOfApplication: {
type: Date,
default: Date.now,
},
dateOfJoining: {
type: Date,
validate: [
{
validator: function (value) {
return this.dateOfApplication <= value;
},
msg: "dateOfJoining should be greater than dateOfApplication",
},
],
},
sop: {
type: String,
validate: {
validator: function (v) {
return v.split(" ").filter((ele) => ele != "").length <= 250;
},
msg: "Statement of purpose should not be greater than 250 words",
},
},
},
{ collation: { locale: "en" } }
);
// schema.virtual("applicationUser", {
// ref: "JobApplicantInfo",
// localField: "userId",
// foreignField: "userId",
// justOne: true,
// });
// schema.virtual("applicationRecruiter", {
// ref: "RecruiterInfo",
// localField: "recruiterId",
// foreignField: "userId",
// justOne: true,
// });
// schema.virtual("applicationJob", {
// ref: "jobs",
// localField: "jobId",
// foreignField: "_id",
// justOne: true,
// });
const ff = { Application: mongoose.model("applications", schema) };
module.exports = ff;