rlz-engine 1.0.27 → 1.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,18 +20,22 @@ export class MongoStorage {
20
20
  const knownIndexes = await this.listIndexes(collection);
21
21
  this.logger.info({ indexes: Array.from(knownIndexes), collection: collection.collectionName }, 'Known indexes');
22
22
  knownIndexes.delete('_id_');
23
+ const indexesToCreate = [];
23
24
  for (const index of indexes) {
24
25
  if (knownIndexes.has(index.name)) {
25
26
  knownIndexes.delete(index.name);
26
27
  continue;
27
28
  }
28
- this.logger.info({ index, collection: collection.collectionName }, 'Create index');
29
- await collection.createIndexes([index]);
29
+ indexesToCreate.push(index);
30
30
  }
31
31
  for (const name of knownIndexes) {
32
32
  this.logger.info({ index: name, collection: collection.collectionName }, 'Drop index');
33
33
  await collection.dropIndex(name);
34
34
  }
35
+ for (const index of indexesToCreate) {
36
+ this.logger.info({ index, collection: collection.collectionName }, 'Create index');
37
+ await collection.createIndexes([index]);
38
+ }
35
39
  }
36
40
  async listIndexes(collection) {
37
41
  const indexes = await collection.listIndexes().toArray();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rlz-engine",
3
- "version": "1.0.27",
3
+ "version": "1.0.28",
4
4
  "description": "Deps and tools for my style of development",
5
5
  "scripts": {
6
6
  "build": "tsc",