@bluedot-innovation/models 2.0.4 → 2.0.5-alpha.2

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 CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.0.5
2
+ - Beacon using a `location` property instead of `latitude` and `longitude` on the root
3
+ - ZoneBeacon model inheriting from Beacon, adds `proximity` and `type`
4
+ - Zone will use ZoneBeacon instead of Beacon model
5
+ - Removed `proximity` from Beacon
6
+
1
7
  ## 2.0.4
2
8
  - customData no longer an array
3
9
  - add accountId to zones
package/models/Beacon.js CHANGED
@@ -6,17 +6,7 @@ let patcher = require('mongoose-json-patch')
6
6
 
7
7
  let schema = {
8
8
  _id: {type: String, default: uuidv4},
9
- name: {type: String, required: [true, 'name is required. ']},
10
- longitude: {
11
- type: Number,
12
- required: true,
13
- validate: [{validator: validateLongitude, msg: 'Longitude is required (insert format here)'}]
14
- },
15
- latitude: {
16
- type: Number,
17
- required: true,
18
- validate: [{validator: validateLatitude, msg: 'Latitude is required (insert format here)'}]
19
- },
9
+ name: {type: String, required: [true, 'name is required.']},
20
10
  description: {type: String, default: ''},
21
11
  creationTime: {type: Date, default: Date.now},
22
12
  lastUpdateTime: {type: Date, default: Date.now},
package/models/Zone.js CHANGED
@@ -13,7 +13,8 @@ let circleSchema = require('./Circle').circleSchema
13
13
  let boundingBoxSchema = require('./BoundingBox').boundingBoxSchema
14
14
  let polylineSchema = require('./Polyline').polylineSchema
15
15
  let polygonSchema = require('./Polygon').polygonSchema
16
- let beaconSchema = require('./Beacon').beaconSchema
16
+ // let beaconSchema = require('./Beacon').beaconSchema
17
+ let beaconSchema = require('./ZoneBeacon').Schema.obj
17
18
  let speedFilterSchema = require('./SpeedFilter').speedFilterSchema
18
19
  let bearingFilterSchema = require('./BearingFilter').bearingFilterSchema
19
20
  let timeOfDayRangeFilterSchema = require('./TimeOfDayRangeFilter').timeOfDayRangeFilterSchema
@@ -1,24 +1,12 @@
1
- /* eslint-disable */
2
1
  let mongoose = require('mongoose')
3
- let Beacon = require('./Beacon').Model
2
+ let Beacon = require('./Beacon').Model()
4
3
 
5
- var options = {discriminatorKey: 'type'};
6
- const ZoneBeacon = Beacon.discriminator('beacon', new mongoose.Schema({
7
- proximity: {type: String, default: 'Far'}
8
- }, options));
9
-
10
- var eventSchema = new mongoose.Schema({time: Date}, options);
11
- var Event = mongoose.model('Event', eventSchema);
4
+ var options = {discriminatorKey: 'type'}
12
5
 
13
- // ClickedLinkEvent is a special type of Event that has a URL.
14
- var ClickedLinkEvent = Event.discriminator('ClickedLink', new mongoose.Schema({url: String}, options));
6
+ const ZoneBeaconSchema = new mongoose.Schema({
7
+ proximity: {type: String, default: 'Far'}
8
+ }, options)
15
9
 
16
- // When you create a generic event, it can't have a URL field...
17
- var genericEvent = new Event({time: Date.now(), url: 'google.com'});
18
- console.log(genericEvent)
19
- console.log(genericEvent instanceof ClickedLinkEvent)
10
+ const ZoneBeacon = Beacon.discriminator('beacon', ZoneBeaconSchema)
20
11
 
21
- // But a ClickedLinkEvent can
22
- var clickedEvent = new ClickedLinkEvent({time: Date.now(), url: 'google.com'});
23
- console.log(clickedEvent)
24
- console.log(clickedEvent instanceof ClickedLinkEvent)
12
+ module.exports = { Model: ZoneBeacon, Schema: ZoneBeaconSchema }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "2.0.4",
3
+ "version": "2.0.5-alpha.2",
4
4
  "description": "",
5
5
  "main": "Models.js",
6
6
  "scripts": {