Do not attach collection to index if duplicate.

This commit is contained in:
Julien Fontanet 2015-05-19 14:42:11 +02:00
parent 644ebd0a4f
commit e963938016

View File

@ -178,14 +178,15 @@ export default class Collection extends EventEmitter {
// -----------------------------------------------------------------
createIndex (name, index) {
index._attachCollection(this)
const {_indexes: indexes} = this
if (hasOwnProperty.call(indexes, name)) {
throw new DuplicateIndex(name)
}
indexes[name] = index
this._indexedItems[name] = index.items
index._attachCollection(this)
}
deleteIndex (name) {