@bluedot-innovation/models 2.0.9 → 2.0.11-alpha.1
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/CHANGELOG.md +8 -0
- package/models/Account.js +1 -0
- package/models/Beacon.js +16 -11
- package/models/BearingFilter.js +4 -7
- package/models/Project.js +1 -0
- package/models/User.js +2 -0
- package/models/Zone.js +1 -1
- package/models/ZoneBeacon.js +3 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
## 2.0.11
|
|
2
|
+
- Added uuid as `_id` for user
|
|
3
|
+
|
|
4
|
+
## 2.0.10
|
|
5
|
+
- Added indexes on beacons model
|
|
6
|
+
- Added `apiKey` to project model (for backwards compatability)
|
|
7
|
+
- Added `customerApiKey` to account model (for backwards compatability)
|
|
8
|
+
|
|
1
9
|
## 2.0.9
|
|
2
10
|
- Validation on `projectPermissions` in user model
|
|
3
11
|
|
package/models/Account.js
CHANGED
|
@@ -12,6 +12,7 @@ const helpers = require('../helpers')
|
|
|
12
12
|
|
|
13
13
|
let AccountSchema = new mongoose.Schema({
|
|
14
14
|
_id: {type: String, default: uuidv4},
|
|
15
|
+
customerApiKey: {type: String, default: uuidv4}, // Backwards compatability
|
|
15
16
|
name: {type: String, required: true},
|
|
16
17
|
createdBy: {
|
|
17
18
|
// type: Schema.Types.ObjectId,
|
package/models/Beacon.js
CHANGED
|
@@ -7,7 +7,6 @@ let patcher = require('mongoose-json-patch')
|
|
|
7
7
|
|
|
8
8
|
let schema = {
|
|
9
9
|
_id: {type: String, default: uuidv4},
|
|
10
|
-
geometry: {type: PointGeometry},
|
|
11
10
|
name: {type: String, required: [true, 'name is required.']},
|
|
12
11
|
description: {type: String, default: ''},
|
|
13
12
|
creationTime: {type: Date, default: Date.now},
|
|
@@ -23,9 +22,8 @@ let schema = {
|
|
|
23
22
|
}
|
|
24
23
|
},
|
|
25
24
|
location: {type: Point, required: true},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
25
|
+
geometry: {type: PointGeometry},
|
|
26
|
+
accountId: {type: String, required: true},
|
|
29
27
|
// These must be unique
|
|
30
28
|
major: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Major needs to be within range(1-65535)'}]},
|
|
31
29
|
minor: {type: Number, validate: [{validator: validateMajorMinor, msg: 'Minor needs to be within range(1-65535)'}]},
|
|
@@ -34,7 +32,14 @@ let schema = {
|
|
|
34
32
|
proximityUUID: {type: String}
|
|
35
33
|
}
|
|
36
34
|
|
|
37
|
-
let BeaconSchema = new mongoose.Schema(schema, {collection: 'beacon'})
|
|
35
|
+
let BeaconSchema = new mongoose.Schema(schema, {collection: 'beacon', autoIndex: false})
|
|
36
|
+
|
|
37
|
+
BeaconSchema.index({ macAddress: 1 })
|
|
38
|
+
BeaconSchema.index({ proximityUUID: 1, major: 1, minor: 1 })
|
|
39
|
+
BeaconSchema.index({ accountId: 1, geometry: '2dsphere' })
|
|
40
|
+
|
|
41
|
+
// accountId: 1, geometry: "2dsphere"
|
|
42
|
+
|
|
38
43
|
BeaconSchema.plugin(patcher)
|
|
39
44
|
|
|
40
45
|
// mongoose validator helper plugin
|
|
@@ -74,12 +79,12 @@ function validateBeaconType (v, magicCallback) {
|
|
|
74
79
|
|
|
75
80
|
// optional mongoose
|
|
76
81
|
let model = (mongooseInstance) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
82
|
+
const instance = mongooseInstance || mongoose
|
|
83
|
+
let Beacon = instance.model('Beacon', BeaconSchema)
|
|
84
|
+
|
|
85
|
+
Beacon.on('index', function (error) {
|
|
86
|
+
console.log(error.message)
|
|
87
|
+
})
|
|
83
88
|
|
|
84
89
|
return Beacon
|
|
85
90
|
}
|
package/models/BearingFilter.js
CHANGED
|
@@ -7,15 +7,12 @@ const schema = {
|
|
|
7
7
|
toAngle: {type: Number, required: true, min: 0, max: 359, validate: {isAsync: true, validator: validateAngles, msg: 'default error message'}}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
const BearingFilterSchema = new mongoose.Schema(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
versionKey: false
|
|
14
|
-
})
|
|
10
|
+
const BearingFilterSchema = new mongoose.Schema(schema, {
|
|
11
|
+
versionKey: false
|
|
12
|
+
})
|
|
15
13
|
|
|
16
14
|
BearingFilterSchema.add({
|
|
17
|
-
type:
|
|
18
|
-
{type: String, required: true}
|
|
15
|
+
type: {type: String, required: true}
|
|
19
16
|
})
|
|
20
17
|
|
|
21
18
|
function validateAngles (toAngle, magicCallback) {
|
package/models/Project.js
CHANGED
|
@@ -15,6 +15,7 @@ let WebhookSchema = require('../schemas/Webhook')
|
|
|
15
15
|
|
|
16
16
|
let ProjectSchema = new mongoose.Schema({
|
|
17
17
|
_id: {type: String, default: uuidv4},
|
|
18
|
+
apiKey: {type: String, default: uuidv4}, // Backwards compatability
|
|
18
19
|
state: {type: String, default: StateEnum.active},
|
|
19
20
|
nextRuleUpdateInterval: {
|
|
20
21
|
type: Number,
|
package/models/User.js
CHANGED
|
@@ -8,8 +8,10 @@ const mongoose = require('mongoose')
|
|
|
8
8
|
const patcher = require('mongoose-json-patch')
|
|
9
9
|
const helpers = require('../helpers')
|
|
10
10
|
const ProjectPermission = require('../schemas/ProjectPermission')
|
|
11
|
+
const uuidv4 = require('uuid/v4')
|
|
11
12
|
|
|
12
13
|
let UserSchema = new mongoose.Schema({
|
|
14
|
+
_id: {type: String, default: uuidv4},
|
|
13
15
|
username: {
|
|
14
16
|
type: String,
|
|
15
17
|
required: true,
|
package/models/Zone.js
CHANGED
package/models/ZoneBeacon.js
CHANGED
|
@@ -14,8 +14,9 @@ schema.proximity = {
|
|
|
14
14
|
const ZoneBeaconSchema = new mongoose.Schema(schema)
|
|
15
15
|
|
|
16
16
|
// optional mongoose
|
|
17
|
-
let model = (mongooseInstance
|
|
18
|
-
|
|
17
|
+
let model = (mongooseInstance) => {
|
|
18
|
+
const instance = mongooseInstance || mongoose
|
|
19
|
+
return instance.model('ZoneBeacon', ZoneBeaconSchema)
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
// Exports Mongoose Model, Mongoose Schema, JSON schema (required locally for discriminators)
|