diff --git a/packages/xo-collection/src/collection.js b/packages/xo-collection/src/collection.js index 72de3294e..c2f2684ff 100644 --- a/packages/xo-collection/src/collection.js +++ b/packages/xo-collection/src/collection.js @@ -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) {