payservedb 1.1.4 → 1.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +2 -5
- package/package.json +1 -1
- package/src/models/brian.js +6 -0
- package/src/models/customer.js +54 -110
- package/src/models/facility.js +1 -5
- package/src/models/units.js +27 -35
- package/src/models/waterMeterSetting.js +25 -0
- package/src/models/access.js +0 -38
- package/src/models/contract.js +0 -39
- package/src/models/guard.js +0 -54
- package/src/models/levy.js +0 -49
- package/src/models/unitasset.js +0 -25
- package/src/models/visitor.js +0 -73
package/index.js
CHANGED
|
@@ -63,11 +63,8 @@ const models = {
|
|
|
63
63
|
SMSAfricastalking: require('./src/models/sms_africastalking'),
|
|
64
64
|
SMSMeliora: require('./src/models/sms_meliora'),
|
|
65
65
|
WaterConcentrator:require('./src/models/waterConcentrator'),
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
Visitor: require('./src/models/visitor'),
|
|
69
|
-
Access: require('./src/models/access'),
|
|
70
|
-
Guard: require('./src/models/guard'),
|
|
66
|
+
WaterMeterSettings:require('./src/models/waterMeterSetting'),
|
|
67
|
+
Brian:require('./src/models/brian')
|
|
71
68
|
};
|
|
72
69
|
|
|
73
70
|
// Function to get models dynamically from a specific database connection
|
package/package.json
CHANGED
package/src/models/customer.js
CHANGED
|
@@ -1,132 +1,76 @@
|
|
|
1
1
|
const mongoose = require('mongoose');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const customerSchema = new mongoose.Schema({
|
|
5
|
-
customerNumber: {
|
|
6
|
-
type: Number,
|
|
7
|
-
required: [true, 'Customer number is required'],
|
|
8
|
-
unique: true // Ensure customer number is unique
|
|
9
|
-
},
|
|
3
|
+
const VisitorSchema = new mongoose.Schema({
|
|
10
4
|
firstName: {
|
|
11
5
|
type: String,
|
|
12
|
-
required:
|
|
13
|
-
trim: true
|
|
6
|
+
required: true,
|
|
14
7
|
},
|
|
15
8
|
lastName: {
|
|
16
9
|
type: String,
|
|
17
|
-
required:
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
email: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: [true, 'Email is required'],
|
|
23
|
-
unique: true, // Ensure email uniqueness for data integrity
|
|
24
|
-
lowercase: true, // Normalize email to lowercase
|
|
25
|
-
trim: true,
|
|
26
|
-
match: [/\S+@\S+\.\S+/, 'Email format is invalid'] // Validate email format
|
|
10
|
+
required: true,
|
|
27
11
|
},
|
|
28
12
|
phoneNumber: {
|
|
29
13
|
type: String,
|
|
30
|
-
required:
|
|
31
|
-
trim: true
|
|
14
|
+
required: true,
|
|
32
15
|
},
|
|
33
16
|
idNumber: {
|
|
34
17
|
type: String,
|
|
35
|
-
required:
|
|
36
|
-
trim: true
|
|
37
|
-
},
|
|
38
|
-
nextOfKinName: {
|
|
39
|
-
type: String,
|
|
40
|
-
required: [true, 'Next of kin name is required'],
|
|
41
|
-
trim: true
|
|
42
|
-
},
|
|
43
|
-
nextOfKinRelationship: {
|
|
44
|
-
type: String,
|
|
45
|
-
required: [true, 'Next of kin relationship is required'],
|
|
46
|
-
trim: true
|
|
18
|
+
required: true,
|
|
47
19
|
},
|
|
48
|
-
|
|
20
|
+
vehicleRegistration: {
|
|
49
21
|
type: String,
|
|
50
|
-
required:
|
|
51
|
-
trim: true
|
|
22
|
+
required: true,
|
|
52
23
|
},
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
required: [true, 'Family member name is required'],
|
|
68
|
-
trim: true
|
|
69
|
-
},
|
|
70
|
-
phone: {
|
|
71
|
-
type: String,
|
|
72
|
-
required: [true, 'Family member phone number is required'],
|
|
73
|
-
trim: true
|
|
24
|
+
familyMembers: [
|
|
25
|
+
{
|
|
26
|
+
name: {
|
|
27
|
+
type: String,
|
|
28
|
+
required: true,
|
|
29
|
+
},
|
|
30
|
+
phoneNumber: {
|
|
31
|
+
type: String,
|
|
32
|
+
required: true,
|
|
33
|
+
},
|
|
34
|
+
relation: {
|
|
35
|
+
type: String,
|
|
36
|
+
required: true,
|
|
37
|
+
},
|
|
74
38
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
39
|
+
],
|
|
40
|
+
staff: [
|
|
41
|
+
{
|
|
42
|
+
name: {
|
|
43
|
+
type: String,
|
|
44
|
+
required: true,
|
|
45
|
+
},
|
|
46
|
+
phoneNumber: {
|
|
47
|
+
type: String,
|
|
48
|
+
required: true,
|
|
49
|
+
},
|
|
50
|
+
jobRole: {
|
|
51
|
+
type: String,
|
|
52
|
+
required: true,
|
|
53
|
+
},
|
|
86
54
|
},
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
55
|
+
],
|
|
56
|
+
vehicles: [
|
|
57
|
+
{
|
|
58
|
+
name: {
|
|
59
|
+
type: String,
|
|
60
|
+
required: true,
|
|
61
|
+
},
|
|
62
|
+
model: {
|
|
63
|
+
type: String,
|
|
64
|
+
required: true,
|
|
65
|
+
},
|
|
66
|
+
plateNumber: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: true,
|
|
69
|
+
},
|
|
91
70
|
},
|
|
92
|
-
|
|
93
|
-
type: String,
|
|
94
|
-
required: [true, 'Vehicle number is required'],
|
|
95
|
-
trim: true
|
|
96
|
-
}
|
|
97
|
-
}],
|
|
98
|
-
staff: [{
|
|
99
|
-
name: {
|
|
100
|
-
type: String,
|
|
101
|
-
required: [true, 'Staff member name is required'],
|
|
102
|
-
trim: true
|
|
103
|
-
},
|
|
104
|
-
phone: {
|
|
105
|
-
type: String,
|
|
106
|
-
required: [true, 'Staff member phone number is required'],
|
|
107
|
-
trim: true
|
|
108
|
-
},
|
|
109
|
-
job: {
|
|
110
|
-
type: String,
|
|
111
|
-
required: [true, 'Staff member name is required'],
|
|
112
|
-
trim: true
|
|
113
|
-
}
|
|
114
|
-
}],
|
|
115
|
-
isEnabled: { type: Boolean, default: false },
|
|
116
|
-
facilityId: {
|
|
117
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
118
|
-
ref: 'Facility',
|
|
119
|
-
required: [true, 'Facility ID is required']
|
|
120
|
-
}
|
|
121
|
-
}, {
|
|
122
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
71
|
+
],
|
|
123
72
|
});
|
|
124
73
|
|
|
125
|
-
|
|
126
|
-
customerSchema.index({ email: 1 });
|
|
127
|
-
customerSchema.index({ customerNumber: 1 });
|
|
128
|
-
|
|
129
|
-
// Compile the model from the schema
|
|
130
|
-
const Customer = mongoose.model('Customer', customerSchema);
|
|
74
|
+
const Visitor = mongoose.model('Visitor', VisitorSchema);
|
|
131
75
|
|
|
132
|
-
module.exports =
|
|
76
|
+
module.exports = Visitor;
|
package/src/models/facility.js
CHANGED
|
@@ -24,11 +24,7 @@ const facilitySchema = new mongoose.Schema({
|
|
|
24
24
|
type: String,
|
|
25
25
|
trim: false,
|
|
26
26
|
default: null
|
|
27
|
-
}
|
|
28
|
-
units: [{
|
|
29
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
30
|
-
ref: 'Unit' // Reference to the Unit model
|
|
31
|
-
}]
|
|
27
|
+
}
|
|
32
28
|
|
|
33
29
|
}, {
|
|
34
30
|
timestamps: true // Automatically add createdAt and updatedAt fields
|
package/src/models/units.js
CHANGED
|
@@ -6,52 +6,44 @@ const unitSchema = new mongoose.Schema({
|
|
|
6
6
|
type: String,
|
|
7
7
|
required: true
|
|
8
8
|
},
|
|
9
|
-
unitType:
|
|
10
|
-
type:
|
|
11
|
-
required:
|
|
9
|
+
unitType:{
|
|
10
|
+
type:String,
|
|
11
|
+
required:true
|
|
12
12
|
},
|
|
13
|
-
division:
|
|
14
|
-
type:
|
|
15
|
-
required:
|
|
13
|
+
division:{
|
|
14
|
+
type:String,
|
|
15
|
+
required:true
|
|
16
16
|
},
|
|
17
|
-
floorUnitNo:
|
|
18
|
-
type:
|
|
19
|
-
required:
|
|
17
|
+
floorUnitNo:{
|
|
18
|
+
type:String,
|
|
19
|
+
required:true
|
|
20
20
|
},
|
|
21
|
-
lettableFloorArea:
|
|
22
|
-
type:
|
|
23
|
-
required:
|
|
21
|
+
lettableFloorArea:{
|
|
22
|
+
type:String,
|
|
23
|
+
required:false
|
|
24
24
|
},
|
|
25
|
-
landRateNumber:
|
|
26
|
-
type:
|
|
27
|
-
required:
|
|
25
|
+
landRateNumber:{
|
|
26
|
+
type:String,
|
|
27
|
+
required:false
|
|
28
28
|
},
|
|
29
|
-
grossArea:
|
|
30
|
-
type:
|
|
31
|
-
required:
|
|
29
|
+
grossArea:{
|
|
30
|
+
type:Number,
|
|
31
|
+
required:false
|
|
32
32
|
},
|
|
33
|
-
netLettableArea:
|
|
34
|
-
type:
|
|
35
|
-
required:
|
|
33
|
+
netLettableArea:{
|
|
34
|
+
type:Number,
|
|
35
|
+
required:false
|
|
36
36
|
},
|
|
37
|
-
status:
|
|
38
|
-
type:
|
|
39
|
-
required:
|
|
37
|
+
status:{
|
|
38
|
+
type:String,
|
|
39
|
+
required:true
|
|
40
40
|
},
|
|
41
|
-
facilityId:
|
|
41
|
+
facilityId:{
|
|
42
42
|
type: mongoose.Schema.Types.ObjectId,
|
|
43
43
|
ref: 'Facility',
|
|
44
|
-
},
|
|
45
|
-
homeOwnerId: {
|
|
46
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
47
|
-
ref: 'Customer',
|
|
48
|
-
},
|
|
49
|
-
tenantId: {
|
|
50
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
51
|
-
ref: 'Customer',
|
|
52
44
|
}
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
|
|
46
|
+
|
|
55
47
|
}, {
|
|
56
48
|
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
57
49
|
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const mongoose = require('mongoose');
|
|
2
|
+
|
|
3
|
+
const waterMeterSettingsSchema = mongoose.Schema({
|
|
4
|
+
manufacturers: {
|
|
5
|
+
type: [String],
|
|
6
|
+
required: false
|
|
7
|
+
},
|
|
8
|
+
meterSizes: {
|
|
9
|
+
type: [String],
|
|
10
|
+
required: false
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
// Middleware to ensure only one record exists
|
|
15
|
+
waterMeterSettingsSchema.pre('save', async function (next) {
|
|
16
|
+
const existingSettings = await WaterMeterSettings.findOne();
|
|
17
|
+
if (existingSettings && !existingSettings._id.equals(this._id)) {
|
|
18
|
+
throw new Error('Only one water meter settings record is allowed.');
|
|
19
|
+
}
|
|
20
|
+
next();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const WaterMeterSettings = mongoose.model("WaterMeterSettings", waterMeterSettingsSchema);
|
|
24
|
+
|
|
25
|
+
module.exports = WaterMeterSettings;
|
package/src/models/access.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const accessSchema = new mongoose.Schema({
|
|
5
|
-
name: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'Name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
location: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Location is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
purpose: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Purpose is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
disabled: {
|
|
21
|
-
type: Boolean,
|
|
22
|
-
default: false,
|
|
23
|
-
},
|
|
24
|
-
facilityId: {
|
|
25
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
26
|
-
ref: 'Facility',
|
|
27
|
-
},
|
|
28
|
-
}, {
|
|
29
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
// Indexes for improved performance
|
|
33
|
-
accessSchema.index({ name: 1 });
|
|
34
|
-
|
|
35
|
-
// Compile the model from the schema
|
|
36
|
-
const Access = mongoose.model('Access', accessSchema);
|
|
37
|
-
|
|
38
|
-
module.exports = Access;
|
package/src/models/contract.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const contractSchema = new mongoose.Schema({
|
|
5
|
-
contractName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'Contract Name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
contractPhoneNumber: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Phone number is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
contractStart: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Start date is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
contractEnd: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: [true, 'Contract end date is required'],
|
|
23
|
-
trim: true
|
|
24
|
-
},
|
|
25
|
-
facilityId: {
|
|
26
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
27
|
-
ref: 'Facility',
|
|
28
|
-
},
|
|
29
|
-
}, {
|
|
30
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Indexes for improved performance
|
|
34
|
-
contractSchema.index({ name: 1 });
|
|
35
|
-
|
|
36
|
-
// Compile the model from the schema
|
|
37
|
-
const Contract = mongoose.model('Contract', contractSchema);
|
|
38
|
-
|
|
39
|
-
module.exports = Contract;
|
package/src/models/guard.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const guardSchema = new mongoose.Schema({
|
|
5
|
-
firstName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'First name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
lastName: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Last name is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
phoneNumber: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Phone number is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
entryPoint: {
|
|
21
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
22
|
-
required: [true, 'Entry point is required'],
|
|
23
|
-
trim: true,
|
|
24
|
-
ref: 'Access'
|
|
25
|
-
},
|
|
26
|
-
startTime: {
|
|
27
|
-
type: String,
|
|
28
|
-
required: [true, 'Start time is required'],
|
|
29
|
-
trim: true
|
|
30
|
-
},
|
|
31
|
-
endTime: {
|
|
32
|
-
type: String,
|
|
33
|
-
required: [true, 'End time is required'],
|
|
34
|
-
trim: true
|
|
35
|
-
},
|
|
36
|
-
disabled: {
|
|
37
|
-
type: Boolean,
|
|
38
|
-
default: false,
|
|
39
|
-
},
|
|
40
|
-
facilityId: {
|
|
41
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
42
|
-
ref: 'Facility',
|
|
43
|
-
},
|
|
44
|
-
}, {
|
|
45
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// Indexes for improved performance
|
|
49
|
-
guardSchema.index({ firstName: 1 });
|
|
50
|
-
|
|
51
|
-
// Compile the model from the schema
|
|
52
|
-
const Guard = mongoose.model('Guard', guardSchema);
|
|
53
|
-
|
|
54
|
-
module.exports = Guard;
|
package/src/models/levy.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const levySchema = new mongoose.Schema({
|
|
5
|
-
levyName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'Levy Name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
levyType: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Levy type is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
levyApplicant: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Levy Applicant is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
collectionFrequency: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: [true, 'Collection frequency is required'],
|
|
23
|
-
trim: true
|
|
24
|
-
},
|
|
25
|
-
invoiceDate: {
|
|
26
|
-
type: String,
|
|
27
|
-
required: [true, 'Date is required'],
|
|
28
|
-
trim: true
|
|
29
|
-
},
|
|
30
|
-
amount: {
|
|
31
|
-
type: String,
|
|
32
|
-
required: [true, 'Amount is required'],
|
|
33
|
-
trim: true
|
|
34
|
-
},
|
|
35
|
-
facilityId: {
|
|
36
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
37
|
-
ref: 'Facility',
|
|
38
|
-
},
|
|
39
|
-
}, {
|
|
40
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Indexes for improved performance
|
|
44
|
-
levySchema.index({ name: 1 });
|
|
45
|
-
|
|
46
|
-
// Compile the model from the schema
|
|
47
|
-
const Levy = mongoose.model('Levy', levySchema);
|
|
48
|
-
|
|
49
|
-
module.exports = Levy;
|
package/src/models/unitasset.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for companies
|
|
4
|
-
const unitassetSchema = new mongoose.Schema({
|
|
5
|
-
name: {
|
|
6
|
-
type: String,
|
|
7
|
-
required:true
|
|
8
|
-
},
|
|
9
|
-
unitId:{
|
|
10
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
11
|
-
ref: 'Unit',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}, {
|
|
16
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// Indexes for improved performance
|
|
20
|
-
unitassetSchema.index({ name: 1 });
|
|
21
|
-
|
|
22
|
-
// Compile the model from the schema
|
|
23
|
-
const UnitAsset = mongoose.model('UnitAsset', unitassetSchema);
|
|
24
|
-
|
|
25
|
-
module.exports = UnitAsset;
|
package/src/models/visitor.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const mongoose = require('mongoose');
|
|
2
|
-
|
|
3
|
-
// Define the schema for customers
|
|
4
|
-
const visitorSchema = new mongoose.Schema({
|
|
5
|
-
firstName: {
|
|
6
|
-
type: String,
|
|
7
|
-
required: [true, 'First name is required'],
|
|
8
|
-
trim: true
|
|
9
|
-
},
|
|
10
|
-
lastName: {
|
|
11
|
-
type: String,
|
|
12
|
-
required: [true, 'Last name is required'],
|
|
13
|
-
trim: true
|
|
14
|
-
},
|
|
15
|
-
phoneNumber: {
|
|
16
|
-
type: String,
|
|
17
|
-
required: [true, 'Phone number is required'],
|
|
18
|
-
trim: true
|
|
19
|
-
},
|
|
20
|
-
idNumber: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: [true, 'ID number is required'],
|
|
23
|
-
trim: true
|
|
24
|
-
},
|
|
25
|
-
carRegistration: {
|
|
26
|
-
type: String,
|
|
27
|
-
trim: true
|
|
28
|
-
},
|
|
29
|
-
carMake: {
|
|
30
|
-
type: String,
|
|
31
|
-
trim: true
|
|
32
|
-
},
|
|
33
|
-
carOccupants: {
|
|
34
|
-
type: String,
|
|
35
|
-
trim: true
|
|
36
|
-
},
|
|
37
|
-
carColor: {
|
|
38
|
-
type: String,
|
|
39
|
-
trim: true
|
|
40
|
-
},
|
|
41
|
-
visitorType: {
|
|
42
|
-
type: String,
|
|
43
|
-
trim: true
|
|
44
|
-
},
|
|
45
|
-
entryPoint: {
|
|
46
|
-
type: String,
|
|
47
|
-
trim: true
|
|
48
|
-
},
|
|
49
|
-
houseNumber: {
|
|
50
|
-
type: String,
|
|
51
|
-
trim: true
|
|
52
|
-
},
|
|
53
|
-
resident: {
|
|
54
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
55
|
-
required: [true, 'Resident is required'],
|
|
56
|
-
trim: true,
|
|
57
|
-
ref: 'Customer',
|
|
58
|
-
},
|
|
59
|
-
facilityId: {
|
|
60
|
-
type: mongoose.Schema.Types.ObjectId,
|
|
61
|
-
ref: 'Facility',
|
|
62
|
-
},
|
|
63
|
-
}, {
|
|
64
|
-
timestamps: true // Automatically add createdAt and updatedAt fields
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
// Indexes for improved performance
|
|
68
|
-
visitorSchema.index({ fullName: 1 });
|
|
69
|
-
|
|
70
|
-
// Compile the model from the schema
|
|
71
|
-
const Visitor = mongoose.model('Visitor', visitorSchema);
|
|
72
|
-
|
|
73
|
-
module.exports = Visitor;
|