-
Notifications
You must be signed in to change notification settings - Fork 0
/
Company.js
39 lines (36 loc) · 921 Bytes
/
Company.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
import mongoose from 'mongoose'
import { validateUser, validateLink } from '../utils/validators.js'
const companySchema = mongoose.Schema(
{
name: {
type: String,
required: [true, 'Name is required.'],
minlength: [2, 'Name must be at least 2 characters long.'],
maxlength: [50, 'Name cannot exceed 50 characters.'],
unique: [true, 'Name must be unique.'],
index: true,
trim: true
},
employees: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'User',
validate: {
validator: validateUser,
message: 'Invalid user ID.'
}
}
],
logoPath: {
type: String,
default: '',
validate: {
validator: validateLink,
message: 'Invalid logo path value'
}
}
},
{ timestamps: true }
)
const Company = mongoose.model('Company', companySchema)
export default Company