@bluedot-innovation/models 2.0.19-alpha.6 → 2.0.19-alpha.8
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/models/Zone.js +16 -5
- package/models/geofeatures/Polyline.js +4 -4
- package/package.json +1 -1
package/models/Zone.js
CHANGED
|
@@ -22,7 +22,18 @@ let percentageCrossedFilterSchema = require('./PercentageCrossedFilter').percent
|
|
|
22
22
|
let uuidv4 = require('uuid/v4')
|
|
23
23
|
let patcher = require('mongoose-json-patch')
|
|
24
24
|
let helpers = require('../helpers')
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
const mongooseHidden = require('mongoose-hidden')({defaultHidden: {
|
|
27
|
+
state: true,
|
|
28
|
+
creationTime: true,
|
|
29
|
+
lastUpdateTime: true,
|
|
30
|
+
__v: true,
|
|
31
|
+
secret: true,
|
|
32
|
+
geofeatures: {
|
|
33
|
+
creationTime: true,
|
|
34
|
+
lastUpdateTime: true
|
|
35
|
+
}
|
|
36
|
+
}})
|
|
26
37
|
|
|
27
38
|
// ////// //
|
|
28
39
|
// Schema //
|
|
@@ -70,10 +81,6 @@ let zoneSchema = new Schema({
|
|
|
70
81
|
accountId: {type: String, required: true, validate: {isAsync: false, validator: helpers.validateUUIDv4, msg: 'default error message'}}
|
|
71
82
|
}, {collection: 'zone'})
|
|
72
83
|
|
|
73
|
-
// TODO: Test patcher and include for other schemas if required
|
|
74
|
-
zoneSchema.plugin(patcher)
|
|
75
|
-
zoneSchema.plugin(mongooseHidden)
|
|
76
|
-
|
|
77
84
|
zoneSchema.path('actions').discriminator('url', new Schema(urlActionSchema))
|
|
78
85
|
zoneSchema.path('actions').discriminator('message', new Schema(messageActionSchema))
|
|
79
86
|
|
|
@@ -89,6 +96,10 @@ zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema
|
|
|
89
96
|
zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema))
|
|
90
97
|
zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema))
|
|
91
98
|
|
|
99
|
+
// TODO: Test patcher and include for other schemas if required
|
|
100
|
+
zoneSchema.plugin(patcher)
|
|
101
|
+
zoneSchema.plugin(mongooseHidden)
|
|
102
|
+
|
|
92
103
|
// optional mongoose
|
|
93
104
|
const model = (mongooseInstance) => {
|
|
94
105
|
let Zone
|
|
@@ -8,10 +8,10 @@ const mongooseHidden = require('../../utils/mongooseHidden')
|
|
|
8
8
|
const schema = {
|
|
9
9
|
_id: {type: String, default: uuidv4},
|
|
10
10
|
geometry: {type: MultiLineStringGeometry},
|
|
11
|
-
name: {type: String, required: [true, 'name is required.
|
|
12
|
-
vertices: {type: [Point], required: [true, 'vertices is required.
|
|
13
|
-
creationTime: {type: Date, default: Date.now
|
|
14
|
-
lastUpdateTime: {type: Date, default: Date.now
|
|
11
|
+
name: {type: String, required: [true, 'name is required.']},
|
|
12
|
+
vertices: {type: [Point], required: [true, 'vertices is required.']},
|
|
13
|
+
creationTime: {type: Date, default: Date.now},
|
|
14
|
+
lastUpdateTime: {type: Date, default: Date.now},
|
|
15
15
|
state: {type: String, default: StateEnum.active, select: false}
|
|
16
16
|
}
|
|
17
17
|
|