@orion-js/mongodb 3.0.42 → 3.0.44

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.
@@ -65,9 +65,16 @@ const createCollection = (options) => {
65
65
  collection.loadById = (0, dataLoader_1.loadById)(collection);
66
66
  collection.loadOne = (0, dataLoader_1.loadOne)(collection);
67
67
  collection.loadMany = (0, dataLoader_1.loadMany)(collection);
68
- const createIndexPromise = (0, createIndexes_1.loadIndexes)(collection);
69
- exports.createIndexesPromises.push(createIndexPromise);
70
- collection.createIndexesPromise = createIndexPromise;
68
+ const createIndexes = async () => {
69
+ const createIndexPromise = (0, createIndexes_1.loadIndexes)(collection);
70
+ exports.createIndexesPromises.push(createIndexPromise);
71
+ collection.createIndexesPromise = createIndexPromise;
72
+ return createIndexPromise;
73
+ };
74
+ collection.createIndexes = createIndexes;
75
+ if (!process.env.DONT_CREATE_INDEXES_AUTOMATICALLY) {
76
+ createIndexes();
77
+ }
71
78
  return collection;
72
79
  };
73
80
  exports.default = createCollection;
@@ -116,6 +116,12 @@ export interface Collection<ModelClass = any> {
116
116
  loadOne: DataLoader.LoadOne<ModelClass>;
117
117
  loadMany: DataLoader.LoadMany<ModelClass>;
118
118
  loadById: DataLoader.LoadById<ModelClass>;
119
+ /**
120
+ * Use this function if you are using tests and you pass the
121
+ * env var DONT_CREATE_INDEXES_AUTOMATICALLY and you need to
122
+ * create the indexes for this collection
123
+ */
124
+ createIndexes: () => Promise<string[]>;
119
125
  createIndexesPromise: Promise<string[]>;
120
126
  connectionPromise: Promise<MongoDB.MongoClient>;
121
127
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/mongodb",
3
- "version": "3.0.42",
3
+ "version": "3.0.44",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "ef0e7a088474c899e13146be867dc574032ac588"
41
+ "gitHead": "f4ddba085eebb33ad62cb0e0fbd9b687fafae864"
42
42
  }