-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJob.js
More file actions
135 lines (133 loc) · 3 KB
/
Job.js
File metadata and controls
135 lines (133 loc) · 3 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
const mongoose = require("mongoose");
let schema = new mongoose.Schema(
{
userId: {
type: mongoose.Schema.Types.ObjectId,
required: true,
},
title: {
type: String,
required: true,
},
maxApplicants: {
type: Number,
validate: [
{
validator: Number.isInteger,
msg: "maxApplicants should be an integer",
},
{
validator: function (value) {
return value > 0;
},
msg: "maxApplicants should greater than 0",
},
],
},
maxPositions: {
type: Number,
validate: [
{
validator: Number.isInteger,
msg: "maxPostions should be an integer",
},
{
validator: function (value) {
return value > 0;
},
msg: "maxPositions should greater than 0",
},
],
},
activeApplications: {
type: Number,
default: 0,
validate: [
{
validator: Number.isInteger,
msg: "activeApplications should be an integer",
},
{
validator: function (value) {
return value >= 0;
},
msg: "activeApplications should greater than equal to 0",
},
],
},
acceptedCandidates: {
type: Number,
default: 0,
validate: [
{
validator: Number.isInteger,
msg: "acceptedCandidates should be an integer",
},
{
validator: function (value) {
return value >= 0;
},
msg: "acceptedCandidates should greater than equal to 0",
},
],
},
dateOfPosting: {
type: Date,
default: Date.now,
},
deadline: {
type: Date,
validate: [
{
validator: function (value) {
return this.dateOfPosting < value;
},
msg: "deadline should be greater than dateOfPosting",
},
],
},
skillsets: [String],
jobType: {
type: String,
required: true,
},
duration: {
type: Number,
min: 0,
validate: [
{
validator: Number.isInteger,
msg: "Duration should be an integer",
},
],
},
salary: {
type: Number,
validate: [
{
validator: Number.isInteger,
msg: "Salary should be an integer",
},
{
validator: function (value) {
return value >= 0;
},
msg: "Salary should be positive",
},
],
},
rating: {
type: Number,
max: 5.0,
default: -1.0,
validate: {
validator: function (v) {
return v >= -1.0 && v <= 5.0;
},
msg: "Invalid rating",
},
},
},
{ collation: { locale: "en" } }
);
module.exports = mongoose.model("jobs", schema);