Comparing version 1.0.4 to 1.0.5
@@ -20,2 +20,8 @@ ## [Unreleased] | ||
## [1.0.5] - 2018-07-11 | ||
### Fixed | ||
- Bug in custom mongoDB indexes in discriminators schemas #2 | ||
## [1.0.4] - 2018-07-11 | ||
@@ -529,2 +535,3 @@ | ||
[1.0.5]: https://github.com/Yonirt/moltyjs/compare/v1.0.4...v1.0.5 | ||
[1.0.4]: https://github.com/Yonirt/moltyjs/compare/v1.0.3...v1.0.4 | ||
@@ -531,0 +538,0 @@ [1.0.3]: https://github.com/Yonirt/moltyjs/compare/v1.0.2...v1.0.3 |
@@ -162,6 +162,7 @@ 'use strict'; | ||
Object.keys(schema).forEach(key => { | ||
if ('unique' in schema[key] && schema[key].unique) { | ||
const index = { key: { [key]: 1 }, unique: true, name: key }; | ||
indexes.push(index); | ||
Object.keys(schema).forEach(field => { | ||
if ('unique' in schema[field] && schema[field].unique) { | ||
if (!indexes.some(index => !!index.key[field])) { | ||
indexes.push({ key: { [field]: 1 }, unique: true, name: field }); | ||
} | ||
} | ||
@@ -173,3 +174,2 @@ }); | ||
} | ||
this._indexes[model._modelName] = indexes; | ||
@@ -176,0 +176,0 @@ } |
{ | ||
"name": "moltyjs", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "A tiny ODM for MongoDB with multy tenancy support.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
134403
2480