payservedb 1.3.2 → 1.3.3

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.
@@ -1,25 +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;
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;
@@ -1,39 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- const EntryExitSchema = mongoose.Schema({
4
- name: {
5
- type: String,
6
- required: true
7
- },
8
- location: {
9
- type: String,
10
- required: true,
11
- },
12
- gps: {
13
- lat: {
14
- type: Number,
15
- required: true
16
- },
17
- lng: {
18
- type: Number,
19
- required: true
20
- }
21
- },
22
- disabled:{
23
- type:Boolean,
24
- required:true
25
- },
26
- purpose: {
27
- type: String,
28
- required: true,
29
- enum: ['entry/exit', 'entry', 'exit', 'emergency exit']
30
- },
31
- facilityId: {
32
- type: mongoose.Schema.Types.ObjectId,
33
- ref: 'Facility',
34
- }
35
- });
36
-
37
- const EntryExit = mongoose.model('EntryExit', EntryExitSchema);
38
-
39
- module.exports = EntryExit;
@@ -1,43 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- // Define the schema for guards
4
- const guardSchema = new mongoose.Schema({
5
- firstName: {
6
- type: String,
7
- required: true
8
- },
9
- lastName: {
10
- type: String,
11
- required: true
12
- },
13
- phoneNumber: {
14
- type: String,
15
- required: true
16
- },
17
- entryPoints: [],
18
- startTime: {
19
- type: String,
20
- required: true
21
- },
22
- endTime: {
23
- type: String,
24
- required: true
25
- },
26
- status: {
27
- type: String,
28
- required: true,
29
- enum: ["On Duty", "Off Duty", "On Break", "Absent", "Sick Leave", "Suspended"]
30
- },
31
- facilityId: {
32
- type: mongoose.Schema.Types.ObjectId,
33
- ref: 'Facility',
34
- required: true // Assuming facilityId is required
35
- }
36
- }, {
37
- timestamps: true // Automatically adds createdAt and updatedAt fields
38
- });
39
-
40
- // Compile the model from the schema
41
- const Guard = mongoose.model('Guard', guardSchema);
42
-
43
- module.exports = Guard;
@@ -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;
@@ -1,57 +0,0 @@
1
- const mongoose = require('mongoose');
2
-
3
- // Define the schema for visit logs
4
- const visitLogSchema = new mongoose.Schema({
5
- visitorName: {
6
- type: String,
7
- required: true
8
- },
9
- residentName: {
10
- type: String,
11
- required: false
12
- },
13
- residentId: {
14
- type: mongoose.Schema.Types.ObjectId,
15
- ref: 'Customer',
16
- },
17
- houseNumber: {
18
- type: String,
19
- required: false
20
- },
21
- startTime: {
22
- type: Date, // Changed to Date for better handling of time
23
- required: true
24
- },
25
- endTime: {
26
- type: Date, // Changed to Date for better handling of time
27
- required: false
28
- },
29
- status: {
30
- type: String,
31
- required: true,
32
- enum: ['Scheduled', 'Completed', 'Cancelled'], // Define valid statuses
33
- },
34
- vehicle: {
35
- registration: String,
36
- make: String,
37
- color: String,
38
- occupants: String,
39
- },
40
- visitationCode: {
41
- type: Number,
42
- required: false
43
-
44
- },
45
- facilityId: {
46
- type: mongoose.Schema.Types.ObjectId,
47
- ref: 'Facility',
48
- required: true // Ensures a facilityId is always provided
49
- }
50
- }, {
51
- timestamps: true // Automatically add createdAt and updatedAt fields
52
- });
53
-
54
- // Compile the model from the schema
55
- const VisitLog = mongoose.model('VisitLog', visitLogSchema);
56
-
57
- module.exports = VisitLog;