@bluedot-innovation/models 3.0.0 → 3.0.2-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 CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.0.1
2
+ - DayRange must have at least startTime or endTime or both
3
+
1
4
  ## 3.0.0
2
5
 
3
6
  - Breaking changes:
package/models/Zone.js CHANGED
@@ -83,11 +83,11 @@ zoneSchema.plugin(patcher)
83
83
  zoneSchema.path('actions').discriminator('url', new Schema(urlActionSchema))
84
84
  zoneSchema.path('actions').discriminator('message', new Schema(messageActionSchema))
85
85
 
86
- zoneSchema.path('filters').discriminator('dayRange', new Schema(dayRangeRawSchema))
87
- zoneSchema.path('filters').discriminator('speed', new Schema(speedRawSchema))
88
- zoneSchema.path('filters').discriminator('timeActive', new Schema(timeActiveRawSchema))
89
- zoneSchema.path('filters').discriminator('travelDirection', new Schema(travelDirectionRawSchema))
90
- zoneSchema.path('filters').discriminator('travelPath', new Schema(travelPathRawSchema))
86
+ zoneSchema.path('filters').discriminator('dayRange', new Schema(dayRangeRawSchema, {_id: false}))
87
+ zoneSchema.path('filters').discriminator('speed', new Schema(speedRawSchema, {_id: false}))
88
+ zoneSchema.path('filters').discriminator('timeActive', new Schema(timeActiveRawSchema, {_id: false}))
89
+ zoneSchema.path('filters').discriminator('travelDirection', new Schema(travelDirectionRawSchema, {_id: false}))
90
+ zoneSchema.path('filters').discriminator('travelPath', new Schema(travelPathRawSchema, {_id: false}))
91
91
 
92
92
  zoneSchema.path('geofeatures').discriminator('beacon', new Schema(beaconSchema))
93
93
  zoneSchema.path('geofeatures').discriminator('circle', new Schema(circleSchema))
@@ -15,9 +15,13 @@ DayRangeFilterSchema.add({
15
15
  type: {type: String, required: true}
16
16
  })
17
17
 
18
- function validateDateRange (endDate, magicCallback) {
18
+ function validateDateRange (endDate, callback) {
19
19
  let startDate = this.startDate
20
20
 
21
+ if (!startDate && !endDate) {
22
+ return callback(false, `Must have a startDate, endDate, or both.`)
23
+ }
24
+
21
25
  if (this.startDate) {
22
26
  startDate = new Date(this.startDate)
23
27
  }
@@ -27,9 +31,9 @@ function validateDateRange (endDate, magicCallback) {
27
31
  }
28
32
 
29
33
  if (startDate && endDate && endDate < startDate) {
30
- return magicCallback(false, `startDate has to be less than endDate.`)
34
+ return callback(false, `startDate has to be less than endDate.`)
31
35
  }
32
- magicCallback(true)
36
+ callback(true)
33
37
  }
34
38
 
35
39
  // optional mongoose
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bluedot-innovation/models",
3
- "version": "3.0.0",
3
+ "version": "3.0.2-alpha.1",
4
4
  "main": "Models.js",
5
5
  "scripts": {
6
6
  "lint": "./node_modules/.bin/eslint -c .eslintrc.js ./models/*.js ./__tests__/**/*.js ./__tests__/**/**/*.js ./schemas/*.js",