@bluedot-innovation/models 2.0.19-alpha.2 → 2.0.19-alpha.20
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.js +11 -11
- package/__tests__/filter/bearing/bearingFilter.spec.js +1 -1
- package/models/Project.js +2 -0
- package/models/User.js +3 -0
- package/models/Zone.js +11 -18
- package/models/{Beacon.js → geofeatures/Beacon.js} +11 -8
- package/models/{BoundingBox.js → geofeatures/BoundingBox.js} +18 -15
- package/models/{Circle.js → geofeatures/Circle.js} +13 -9
- package/models/{Polygon.js → geofeatures/Polygon.js} +10 -6
- package/models/{Polyline.js → geofeatures/Polyline.js} +16 -14
- package/models/{ZoneBeacon.js → geofeatures/ZoneBeacon.js} +9 -5
- package/package.json +1 -1
- package/utils/mongooseHidden.js +10 -0
package/Models.js
CHANGED
|
@@ -5,17 +5,17 @@
|
|
|
5
5
|
let Models = {}
|
|
6
6
|
|
|
7
7
|
Models.Account = require('./models/Account').Model
|
|
8
|
-
Models.Beacon = require('./models/Beacon').Model
|
|
8
|
+
Models.Beacon = require('./models/geofeatures/Beacon').Model
|
|
9
9
|
Models.BeaconFilter = require('./models/BeaconFilter').Model
|
|
10
10
|
Models.BearingFilter = require('./models/BearingFilter').Model
|
|
11
|
-
Models.BoundingBox = require('./models/BoundingBox').Model
|
|
11
|
+
Models.BoundingBox = require('./models/geofeatures/BoundingBox').Model
|
|
12
12
|
Models.CalendarDateRangeFilter = require('./models/CalendarDateRangeFilter').Model
|
|
13
|
-
Models.Circle = require('./models/Circle').Model
|
|
13
|
+
Models.Circle = require('./models/geofeatures/Circle').Model
|
|
14
14
|
Models.MessageAction = require('./models/MessageAction').Model
|
|
15
15
|
Models.MonthlyStat = require('./models/MonthlyStats').Model
|
|
16
16
|
Models.PercentageCrossedFilter = require('./models/PercentageCrossedFilter').Model
|
|
17
|
-
Models.Polygon = require('./models/Polygon').Model
|
|
18
|
-
Models.Polyline = require('./models/Polyline').Model
|
|
17
|
+
Models.Polygon = require('./models/geofeatures/Polygon').Model
|
|
18
|
+
Models.Polyline = require('./models/geofeatures/Polyline').Model
|
|
19
19
|
Models.Project = require('./models/Project').Model
|
|
20
20
|
Models.RuleRequestAggregation = require('./models/RuleRequestAggregation').Model
|
|
21
21
|
Models.SpeedFilter = require('./models/SpeedFilter').Model
|
|
@@ -23,22 +23,22 @@ Models.TimeOfDayRangeFilter = require('./models/TimeOfDayRangeFilter').Model
|
|
|
23
23
|
Models.UrlAction = require('./models/UrlAction').Model
|
|
24
24
|
Models.User = require('./models/User').Model
|
|
25
25
|
Models.Zone = require('./models/Zone').Model
|
|
26
|
-
Models.ZoneBeacon = require('./models/ZoneBeacon').Model
|
|
26
|
+
Models.ZoneBeacon = require('./models/geofeatures/ZoneBeacon').Model
|
|
27
27
|
|
|
28
28
|
let Schemas = {}
|
|
29
29
|
|
|
30
30
|
Schemas.Account = require('./models/Account').Schema
|
|
31
|
-
Schemas.Beacon = require('./models/Beacon').Schema
|
|
31
|
+
Schemas.Beacon = require('./models/geofeatures/Beacon').Schema
|
|
32
32
|
Schemas.BeaconFilter = require('./models/BeaconFilter').Schema
|
|
33
33
|
Schemas.BearingFilter = require('./models/BearingFilter').Schema
|
|
34
|
-
Schemas.BoundingBox = require('./models/BoundingBox').Schema
|
|
34
|
+
Schemas.BoundingBox = require('./models/geofeatures/BoundingBox').Schema
|
|
35
35
|
Schemas.CalendarDateRangeFilter = require('./models/CalendarDateRangeFilter').Schema
|
|
36
|
-
Schemas.Circle = require('./models/Circle').Schema
|
|
36
|
+
Schemas.Circle = require('./models/geofeatures/Circle').Schema
|
|
37
37
|
Schemas.MessageAction = require('./models/MessageAction').Schema
|
|
38
38
|
Schemas.MonthlyStat = require('./models/MonthlyStats').Schema
|
|
39
39
|
Schemas.PercentageCrossedFilter = require('./models/PercentageCrossedFilter').Schema
|
|
40
|
-
Schemas.Polygon = require('./models/Polygon').Schema
|
|
41
|
-
Schemas.Polyline = require('./models/Polyline').Schema
|
|
40
|
+
Schemas.Polygon = require('./models/geofeatures/Polygon').Schema
|
|
41
|
+
Schemas.Polyline = require('./models/geofeatures/Polyline').Schema
|
|
42
42
|
Schemas.Project = require('./models/Project').Schema
|
|
43
43
|
Schemas.RuleRequestAggregation = require('./models/RuleRequestAggregation').Schema
|
|
44
44
|
Schemas.SpeedFilter = require('./models/SpeedFilter').Schema
|
|
@@ -2,7 +2,7 @@ let mongoose = require('mongoose')
|
|
|
2
2
|
mongoose.Promise = global.Promise
|
|
3
3
|
|
|
4
4
|
const BearingFilterModel = require('../../../Models').BearingFilter(mongoose)
|
|
5
|
-
const { isMinimumNinetyApart } = require
|
|
5
|
+
const { isMinimumNinetyApart } = require('../../../models/BearingFilter')
|
|
6
6
|
const describe = require('mocha').describe
|
|
7
7
|
const it = require('mocha').it
|
|
8
8
|
const chai = require('chai')
|
package/models/Project.js
CHANGED
|
@@ -9,6 +9,7 @@ let Schema = mongoose.Schema
|
|
|
9
9
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
10
10
|
let uuidv4 = require('uuid/v4')
|
|
11
11
|
let patcher = require('mongoose-json-patch')
|
|
12
|
+
const mongooseHidden = require('../utils/mongooseHidden')
|
|
12
13
|
let helpers = require('../helpers')
|
|
13
14
|
|
|
14
15
|
let WebhookSchema = require('../schemas/Webhook')
|
|
@@ -38,6 +39,7 @@ let ProjectSchema = new mongoose.Schema({
|
|
|
38
39
|
{collection: 'project'})
|
|
39
40
|
|
|
40
41
|
ProjectSchema.plugin(patcher)
|
|
42
|
+
ProjectSchema.plugin(mongooseHidden)
|
|
41
43
|
|
|
42
44
|
// optional mongoose
|
|
43
45
|
let model = (mongooseInstance) => {
|
package/models/User.js
CHANGED
|
@@ -9,6 +9,7 @@ const patcher = require('mongoose-json-patch')
|
|
|
9
9
|
const helpers = require('../helpers')
|
|
10
10
|
const ProjectPermission = require('../schemas/ProjectPermission')
|
|
11
11
|
const uuidv4 = require('uuid/v4')
|
|
12
|
+
const mongooseHidden = require('../utils/mongooseHidden')
|
|
12
13
|
|
|
13
14
|
let UserSchema = new mongoose.Schema({
|
|
14
15
|
_id: {type: String, default: uuidv4},
|
|
@@ -45,6 +46,8 @@ let UserSchema = new mongoose.Schema({
|
|
|
45
46
|
{collection: 'user'})
|
|
46
47
|
|
|
47
48
|
UserSchema.plugin(patcher)
|
|
49
|
+
UserSchema.plugin(mongooseHidden)
|
|
50
|
+
|
|
48
51
|
|
|
49
52
|
// optional mongoose
|
|
50
53
|
let model = (mongooseInstance) => {
|
package/models/Zone.js
CHANGED
|
@@ -9,11 +9,11 @@ let Schema = mongoose.Schema
|
|
|
9
9
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
10
10
|
let messageActionSchema = require('./MessageAction').messageActionSchema
|
|
11
11
|
let urlActionSchema = require('./UrlAction').urlActionSchema
|
|
12
|
-
let circleSchema = require('./Circle').
|
|
13
|
-
let boundingBoxSchema = require('./BoundingBox').
|
|
14
|
-
let polylineSchema = require('./Polyline').
|
|
15
|
-
let polygonSchema = require('./Polygon').
|
|
16
|
-
let beaconSchema = require('./ZoneBeacon').
|
|
12
|
+
let circleSchema = require('./geofeatures/Circle').rawSchema
|
|
13
|
+
let boundingBoxSchema = require('./geofeatures/BoundingBox').rawSchema
|
|
14
|
+
let polylineSchema = require('./geofeatures/Polyline').rawSchema
|
|
15
|
+
let polygonSchema = require('./geofeatures/Polygon').rawSchema
|
|
16
|
+
let beaconSchema = require('./geofeatures/ZoneBeacon').rawSchema
|
|
17
17
|
let speedFilterSchema = require('./SpeedFilter').speedFilterSchema
|
|
18
18
|
let bearingFilterSchema = require('./BearingFilter').bearingFilterSchema
|
|
19
19
|
let timeOfDayRangeFilterSchema = require('./TimeOfDayRangeFilter').timeOfDayRangeFilterSchema
|
|
@@ -22,14 +22,7 @@ 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
|
-
|
|
26
|
-
const mongooseHidden = require('mongoose-hidden')({defaultHidden: {
|
|
27
|
-
_id: false,
|
|
28
|
-
state: true,
|
|
29
|
-
creationTime: true,
|
|
30
|
-
lastUpdateTime: true,
|
|
31
|
-
__v: true
|
|
32
|
-
}})
|
|
25
|
+
const mongooseHidden = require('../utils/mongooseHidden')
|
|
33
26
|
|
|
34
27
|
// ////// //
|
|
35
28
|
// Schema //
|
|
@@ -90,11 +83,11 @@ zoneSchema.path('filters').discriminator('percentageCrossed', new Schema(percent
|
|
|
90
83
|
zoneSchema.path('filters').discriminator('speed', new Schema(speedFilterSchema))
|
|
91
84
|
zoneSchema.path('filters').discriminator('timeOfDayRange', new Schema(timeOfDayRangeFilterSchema))
|
|
92
85
|
|
|
93
|
-
zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema))
|
|
94
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
95
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
96
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
97
|
-
zoneSchema.path('geofeatures').discriminator('
|
|
86
|
+
zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema).plugin(mongooseHidden))
|
|
87
|
+
zoneSchema.path('geofeatures').discriminator('boundingBox', new Schema(boundingBoxSchema).plugin(mongooseHidden))
|
|
88
|
+
zoneSchema.path('geofeatures').discriminator('circle', new Schema(circleSchema).plugin(mongooseHidden))
|
|
89
|
+
zoneSchema.path('geofeatures').discriminator('polygon', new Schema(polygonSchema).plugin(mongooseHidden))
|
|
90
|
+
zoneSchema.path('geofeatures').discriminator('polyline', new Schema(polylineSchema).plugin(mongooseHidden))
|
|
98
91
|
|
|
99
92
|
// optional mongoose
|
|
100
93
|
const model = (mongooseInstance) => {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
const StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
2
|
+
const patcher = require('mongoose-json-patch')
|
|
3
|
+
const mongoose = require('mongoose')
|
|
4
|
+
const uuidv4 = require('uuid/v4')
|
|
5
|
+
const PointGeometry = require('../../schemas/PointGeometry')
|
|
6
|
+
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
7
|
+
const Point = require('../../schemas/Point')
|
|
7
8
|
|
|
8
9
|
let schema = {
|
|
9
10
|
_id: {type: String, default: uuidv4},
|
|
@@ -41,6 +42,7 @@ BeaconSchema.index({ accountId: 1, geometry: '2dsphere' })
|
|
|
41
42
|
// accountId: 1, geometry: "2dsphere"
|
|
42
43
|
|
|
43
44
|
BeaconSchema.plugin(patcher)
|
|
45
|
+
BeaconSchema.plugin(mongooseHidden)
|
|
44
46
|
|
|
45
47
|
// mongoose validator helper plugin
|
|
46
48
|
BeaconSchema.post('validate', function (doc) {
|
|
@@ -78,7 +80,7 @@ function validateBeaconType (v, magicCallback) {
|
|
|
78
80
|
}
|
|
79
81
|
|
|
80
82
|
// optional mongoose
|
|
81
|
-
let
|
|
83
|
+
let BeaconModel = (mongooseInstance) => {
|
|
82
84
|
const instance = mongooseInstance || mongoose
|
|
83
85
|
let Beacon = instance.model('Beacon', BeaconSchema)
|
|
84
86
|
|
|
@@ -88,5 +90,6 @@ let model = (mongooseInstance) => {
|
|
|
88
90
|
|
|
89
91
|
return Beacon
|
|
90
92
|
}
|
|
93
|
+
|
|
91
94
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
92
|
-
module.exports = { Model:
|
|
95
|
+
module.exports = { Model: BeaconModel, Schema: BeaconSchema, rawSchema: schema }
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
let mongoose = require('mongoose')
|
|
2
1
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
2
|
+
let mongoose = require('mongoose')
|
|
3
3
|
let uuidv4 = require('uuid/v4')
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const PolygonGeometry = require('../../schemas/PolygonGeometry')
|
|
5
|
+
const Point = require('../../schemas/Point')
|
|
6
|
+
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
6
7
|
|
|
7
8
|
const schema = {
|
|
8
9
|
_id: {type: String, default: uuidv4},
|
|
@@ -16,28 +17,30 @@ const schema = {
|
|
|
16
17
|
state: {type: String, default: StateEnum.active, select: false}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
versionKey: false
|
|
24
|
-
})
|
|
20
|
+
const boundingBoxSchema = new mongoose.Schema(schema, {
|
|
21
|
+
_id: false,
|
|
22
|
+
versionKey: false
|
|
23
|
+
})
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
// Adding type after, because we need to export the rawSchema without type,
|
|
26
|
+
// since the zone discriminator needs the schema without it
|
|
27
|
+
boundingBoxSchema.add({
|
|
28
|
+
type: {type: String, required: true}
|
|
29
29
|
})
|
|
30
30
|
|
|
31
|
+
boundingBoxSchema.plugin(mongooseHidden)
|
|
32
|
+
|
|
33
|
+
|
|
31
34
|
// optional mongoose
|
|
32
35
|
let model = (mongooseInstance) => {
|
|
33
36
|
let BoundingBox
|
|
34
37
|
if (mongooseInstance) {
|
|
35
|
-
BoundingBox = mongooseInstance.model('BoundingBox',
|
|
38
|
+
BoundingBox = mongooseInstance.model('BoundingBox', boundingBoxSchema)
|
|
36
39
|
} else {
|
|
37
|
-
BoundingBox = mongoose.model('BoundingBox',
|
|
40
|
+
BoundingBox = mongoose.model('BoundingBox', boundingBoxSchema)
|
|
38
41
|
}
|
|
39
42
|
|
|
40
43
|
return BoundingBox
|
|
41
44
|
}
|
|
42
45
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
43
|
-
module.exports = { Model: model, Schema:
|
|
46
|
+
module.exports = { Model: model, Schema: boundingBoxSchema, rawSchema: schema }
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
-
let Point = require('../schemas/Point')
|
|
4
3
|
let uuidv4 = require('uuid/v4')
|
|
5
|
-
|
|
4
|
+
const PolygonGeometry = require('../../schemas/PolygonGeometry')
|
|
5
|
+
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
6
|
+
const Point = require('../../schemas/Point')
|
|
6
7
|
|
|
7
8
|
let schema = {
|
|
8
9
|
_id: {type: String, default: uuidv4},
|
|
@@ -16,28 +17,31 @@ let schema = {
|
|
|
16
17
|
state: {type: String, default: StateEnum.active, select: false}
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
let
|
|
20
|
+
let circleSchema = new mongoose.Schema(
|
|
20
21
|
schema,
|
|
21
22
|
{
|
|
22
23
|
_id: false,
|
|
23
24
|
__v: false
|
|
24
25
|
})
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
// Adding type after, because we need to export the rawSchema without type,
|
|
28
|
+
// since the zone discriminator needs the schema without it
|
|
29
|
+
circleSchema.add({
|
|
30
|
+
type: {type: String, required: true}
|
|
29
31
|
})
|
|
30
32
|
|
|
33
|
+
circleSchema.plugin(mongooseHidden)
|
|
34
|
+
|
|
31
35
|
// optional mongoose
|
|
32
36
|
let model = (mongooseInstance) => {
|
|
33
37
|
let Circle
|
|
34
38
|
if (mongooseInstance) {
|
|
35
|
-
Circle = mongooseInstance.model('Circle',
|
|
39
|
+
Circle = mongooseInstance.model('Circle', circleSchema)
|
|
36
40
|
} else {
|
|
37
|
-
Circle = mongoose.model('Circle',
|
|
41
|
+
Circle = mongoose.model('Circle', circleSchema)
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
return Circle
|
|
41
45
|
}
|
|
42
46
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
43
|
-
module.exports = { Model: model, Schema:
|
|
47
|
+
module.exports = { Model: model, Schema: circleSchema, rawSchema: schema }
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
-
|
|
3
|
+
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
4
|
+
const Point = require('../../schemas/Point')
|
|
4
5
|
let uuidv4 = require('uuid/v4')
|
|
5
6
|
|
|
6
7
|
const schema = {
|
|
@@ -13,28 +14,31 @@ const schema = {
|
|
|
13
14
|
lastUpdateTime: {type: Date, default: Date.now},
|
|
14
15
|
state: {type: String, default: StateEnum.active, select: false}
|
|
15
16
|
}
|
|
16
|
-
const
|
|
17
|
+
const polygonSchema = new mongoose.Schema(
|
|
17
18
|
schema,
|
|
18
19
|
{
|
|
19
20
|
_id: false,
|
|
20
21
|
versionKey: false
|
|
21
22
|
})
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
polygonSchema.add({
|
|
24
25
|
type:
|
|
25
26
|
{type: String, required: true}
|
|
26
27
|
})
|
|
27
28
|
|
|
29
|
+
polygonSchema.plugin(mongooseHidden)
|
|
30
|
+
|
|
31
|
+
|
|
28
32
|
// optional mongoose
|
|
29
33
|
let model = (mongooseInstance) => {
|
|
30
34
|
let Polygon
|
|
31
35
|
if (mongooseInstance) {
|
|
32
|
-
Polygon = mongooseInstance.model('Polygon',
|
|
36
|
+
Polygon = mongooseInstance.model('Polygon', polygonSchema)
|
|
33
37
|
} else {
|
|
34
|
-
Polygon = mongoose.model('Polygon',
|
|
38
|
+
Polygon = mongoose.model('Polygon', polygonSchema)
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
return Polygon
|
|
38
42
|
}
|
|
39
43
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
40
|
-
module.exports = { Model: model, Schema:
|
|
44
|
+
module.exports = { Model: model, Schema: polygonSchema, rawSchema: schema }
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
let mongoose = require('mongoose')
|
|
2
2
|
let StateEnum = require('@bluedot-innovation/enums').StateEnum
|
|
3
|
-
|
|
3
|
+
const Point = require('../../schemas/Point')
|
|
4
4
|
let uuidv4 = require('uuid/v4')
|
|
5
|
-
|
|
5
|
+
const MultiLineStringGeometry = require('../../schemas/MultiLineStringGeometry')
|
|
6
|
+
const mongooseHidden = require('../../utils/mongooseHidden')
|
|
6
7
|
|
|
7
8
|
const schema = {
|
|
8
9
|
_id: {type: String, default: uuidv4},
|
|
@@ -14,28 +15,29 @@ const schema = {
|
|
|
14
15
|
state: {type: String, default: StateEnum.active, select: false}
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
versionKey: false
|
|
22
|
-
})
|
|
18
|
+
const polylineSchema = new mongoose.Schema(schema, {
|
|
19
|
+
_id: false,
|
|
20
|
+
versionKey: false
|
|
21
|
+
})
|
|
23
22
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
// Adding type after, because we need to export the rawSchema without type,
|
|
24
|
+
// since the zone discriminator needs the schema without it
|
|
25
|
+
polylineSchema.add({
|
|
26
|
+
type: {type: String, required: true}
|
|
27
27
|
})
|
|
28
28
|
|
|
29
|
+
polylineSchema.plugin(mongooseHidden)
|
|
30
|
+
|
|
29
31
|
// optional mongoose
|
|
30
32
|
let model = (mongooseInstance) => {
|
|
31
33
|
let Polyline
|
|
32
34
|
if (mongooseInstance) {
|
|
33
|
-
Polyline = mongooseInstance.model('Polyline',
|
|
35
|
+
Polyline = mongooseInstance.model('Polyline', polylineSchema)
|
|
34
36
|
} else {
|
|
35
|
-
Polyline = mongoose.model('Polyline',
|
|
37
|
+
Polyline = mongoose.model('Polyline', polylineSchema)
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
return Polyline
|
|
39
41
|
}
|
|
40
42
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
41
|
-
module.exports = { Model: model, Schema:
|
|
43
|
+
module.exports = { Model: model, Schema: polylineSchema, rawSchema: schema }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const cloneDeep = require('lodash.clonedeep')
|
|
2
2
|
const mongoose = require('mongoose')
|
|
3
|
-
const beaconSchema = require('./Beacon').
|
|
3
|
+
const beaconSchema = require('./Beacon').rawSchema
|
|
4
4
|
const BeaconEnum = require('@bluedot-innovation/enums').BeaconEnum
|
|
5
5
|
|
|
6
6
|
const schema = cloneDeep(beaconSchema)
|
|
@@ -11,13 +11,17 @@ schema.proximity = {
|
|
|
11
11
|
enum: [BeaconEnum.NEAR, BeaconEnum.FAR]
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const
|
|
14
|
+
const zoneBeaconSchema = new mongoose.Schema(schema)
|
|
15
|
+
|
|
16
|
+
zoneBeaconSchema.add({
|
|
17
|
+
type: {type: String, required: true}
|
|
18
|
+
})
|
|
15
19
|
|
|
16
20
|
// optional mongoose
|
|
17
|
-
let
|
|
21
|
+
let ZoneBeaconModel = (mongooseInstance) => {
|
|
18
22
|
const instance = mongooseInstance || mongoose
|
|
19
|
-
return instance.model('ZoneBeacon',
|
|
23
|
+
return instance.model('ZoneBeacon', zoneBeaconSchema)
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|
|
23
|
-
module.exports = { Model:
|
|
27
|
+
module.exports = { Model: ZoneBeaconModel, Schema: zoneBeaconSchema, rawSchema: schema }
|
package/package.json
CHANGED