@justair/justair-library 3.3.4-oscar → 3.3.4-romeo
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/package.json +1 -1
- package/src/models/monitors.js +8 -21
package/package.json
CHANGED
package/src/models/monitors.js
CHANGED
|
@@ -14,18 +14,6 @@ const parametersEnum = [
|
|
|
14
14
|
"WS And Direction",
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
-
const thresholdSchema = new mongoose.Schema({
|
|
18
|
-
invalid: {
|
|
19
|
-
min: Number,
|
|
20
|
-
max: Number
|
|
21
|
-
},
|
|
22
|
-
warning: {
|
|
23
|
-
min: Number,
|
|
24
|
-
max: Number
|
|
25
|
-
}
|
|
26
|
-
}, { _id: false });
|
|
27
|
-
|
|
28
|
-
|
|
29
17
|
// Monitors Schema
|
|
30
18
|
const monitorsSchema = mongoose.Schema(
|
|
31
19
|
{
|
|
@@ -93,21 +81,20 @@ const monitorsSchema = mongoose.Schema(
|
|
|
93
81
|
calculatedAverages: [Object],
|
|
94
82
|
images: [String],
|
|
95
83
|
isActive: { type: Boolean, default: true },
|
|
96
|
-
parameterThresholds: {
|
|
97
|
-
type: mongoose.Schema.Types.Mixed,
|
|
98
|
-
validate: {
|
|
99
|
-
validator: function(v) {
|
|
100
|
-
return Object.keys(v).every(key => parametersEnum.includes(key));
|
|
101
|
-
},
|
|
102
|
-
message: props => `${props.value} is not a valid parameter threshold object`
|
|
103
|
-
}
|
|
104
|
-
} ,
|
|
84
|
+
parameterThresholds: { type: mongoose.Schema.Types.Mixed, }
|
|
105
85
|
},
|
|
106
86
|
{
|
|
107
87
|
timestamps: true,
|
|
108
88
|
}
|
|
109
89
|
);
|
|
110
90
|
|
|
91
|
+
monitorsSchema.path('parameterThresholds').validate({
|
|
92
|
+
validator: function(v) {
|
|
93
|
+
return Object.keys(v).every(key => parametersEnum.includes(key));
|
|
94
|
+
},
|
|
95
|
+
message: props => `${props.value} is not a valid parameter threshold object`
|
|
96
|
+
})
|
|
97
|
+
|
|
111
98
|
monitorsSchema.index({ gpsLocation: "2dsphere" });
|
|
112
99
|
monitorsSchema.index({ monitorSupplier: 1 });
|
|
113
100
|
monitorsSchema.index({ monitorIdFromSupplier: 1 });
|