Comparing version 0.9.7 to 0.9.8
@@ -20,2 +20,8 @@ ## [Unreleased] | ||
## [0.9.8] - 2018-06-08 | ||
### Fixed | ||
- Discriminator schemas did not inherit the timestamp option from the parent | ||
## [0.9.7] - 2018-06-07 | ||
@@ -483,2 +489,3 @@ | ||
[0.9.8]: https://github.com/Yonirt/moltyjs/compare/v0.9.7...v0.9.8 | ||
[0.9.7]: https://github.com/Yonirt/moltyjs/compare/v0.9.6...v0.9.7 | ||
@@ -485,0 +492,0 @@ [0.9.6]: https://github.com/Yonirt/moltyjs/compare/v0.9.5...v0.9.6 |
@@ -198,11 +198,13 @@ 'use strict'; | ||
_applyTimestamps(obj, model, operation) { | ||
if (model._schemaOptions.timestamps && operation === 'insert') { | ||
obj._data['createdAt'] = new Date(); | ||
obj._data['updatedAt'] = new Date(); | ||
} | ||
if (model._schemaOptions.timestamps) { | ||
if (operation === 'insert') { | ||
obj._data['createdAt'] = new Date(); | ||
obj._data['updatedAt'] = new Date(); | ||
} | ||
if (model._schemaOptions.timestamps && operation === 'update') { | ||
obj['$currentDate'] = { | ||
updatedAt: true | ||
}; | ||
if (operation === 'update') { | ||
obj['$currentDate'] = { | ||
updatedAt: true | ||
}; | ||
} | ||
} | ||
@@ -209,0 +211,0 @@ |
@@ -180,2 +180,6 @@ 'use strict'; | ||
if (this._schemaOptions && this._schemaOptions.timestamps) { | ||
schemaAux._options.timestamps = true; | ||
} | ||
schemaAux._schema = Object.assign({}, schemaDiscriminator._schema, this._schemaNormalized); | ||
@@ -182,0 +186,0 @@ |
{ | ||
"name": "moltyjs", | ||
"version": "0.9.7", | ||
"version": "0.9.8", | ||
"description": "A tiny ODM for MongoDB with multy tenancy support.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
131224
2445