Comparing version 1.0.3 to 1.0.4
@@ -20,2 +20,8 @@ ## [Unreleased] | ||
## [1.0.4] - 2018-07-11 | ||
### Fixed | ||
- Bug in custom mongoDB indexes in discriminators schemas | ||
## [1.0.3] - 2018-07-11 | ||
@@ -523,2 +529,3 @@ | ||
[1.0.4]: https://github.com/Yonirt/moltyjs/compare/v1.0.3...v1.0.4 | ||
[1.0.3]: https://github.com/Yonirt/moltyjs/compare/v1.0.2...v1.0.3 | ||
@@ -525,0 +532,0 @@ [1.0.2]: https://github.com/Yonirt/moltyjs/compare/v1.0.1...v1.0.2 |
@@ -160,3 +160,3 @@ 'use strict'; | ||
const schema = model._schemaNormalized; | ||
let indexes = []; | ||
let indexes = this._indexes[model._modelName] ? this._indexes[model._modelName] : []; | ||
@@ -163,0 +163,0 @@ Object.keys(schema).forEach(key => { |
@@ -180,4 +180,12 @@ 'use strict'; | ||
if (this._schemaOptions && this._schemaOptions.timestamps) { | ||
schemaAux._options.timestamps = true; | ||
if (this._schemaOptions) { | ||
// Merge timestamps | ||
if (this._schemaOptions.timestamps) { | ||
schemaAux._options.timestamps = true; | ||
} | ||
// Merge elasticSearchIndexes | ||
if (this._schemaOptions.elasticSearchIndexes) { | ||
schemaAux._options.elasticSearchIndexes = Object.assign({}, schemaAux._options.elasticSearchIndexes, this._schemaOptions.elasticSearchIndexes); | ||
} | ||
} | ||
@@ -184,0 +192,0 @@ |
@@ -119,12 +119,4 @@ 'use strict'; | ||
if (key === 'mongoDBIndexes' && isArray(options[key])) { | ||
if (options[key].length > 0) { | ||
options[key].forEach(mongoDBIndex => { | ||
Object.keys(mongoDBIndex.key).forEach(schemaKey => { | ||
if (Object.keys(this._schema).indexOf(schemaKey) < 0) { | ||
throw new Error('mongoDB indexes must belongs to the Schema, got: ' + schemaKey); | ||
} | ||
}); | ||
}); | ||
} else { | ||
throw new Error('mongoDB indexes shoudl not be empty if it is declared on the schema options'); | ||
if (options[key].length === 0) { | ||
throw new Error('mongoDB indexes should not be empty if it is declared on the schema options'); | ||
} | ||
@@ -131,0 +123,0 @@ } |
{ | ||
"name": "moltyjs", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "A tiny ODM for MongoDB with multy tenancy support.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -308,3 +308,3 @@ [![npm version](https://badge.fury.io/js/moltyjs.svg)](https://badge.fury.io/js/moltyjs) | ||
You can also create models which inherits from other models and you can decide in which fashion you wan to do it. You have to make sure that the discriminator key of the child models are the same than the parents and also set what you want to merge from the parent model. | ||
You can also create models which inherits from other models and you can decide in which fashion you want to do it. You have to make sure that the discriminator key of the child models are the same than the parents and also set what you want to merge from the parent model. | ||
@@ -341,3 +341,3 @@ ### `.discriminator(schema, discriminatorName)` | ||
The **merge** option must be an array with the element you want to merge from the parent model, teh options are: | ||
The **merge** option must be an array with the element you want to merge from the parent model, those options are: | ||
@@ -344,0 +344,0 @@ - methods: which corresponds to the static methods. |
134181
2479