gcf-common-lib 0.22.4 → 0.22.5

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gcf-common-lib",
3
3
  "description": "",
4
- "version": "0.22.4",
4
+ "version": "0.22.5",
5
5
  "publishConfig": {
6
6
  "access": "public",
7
7
  "branches": [
package/src/mongo-lock.js CHANGED
@@ -22,7 +22,13 @@ class MongoLock {
22
22
  }
23
23
  getCollection() {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
- return this.client.db().collection('locks');
25
+ const locksColl = this.client.db().collection('locks');
26
+ yield locksColl.indexExists('expiresAt')
27
+ .then((exists) => __awaiter(this, void 0, void 0, function* () {
28
+ if (!exists)
29
+ yield locksColl.createIndex({ "expiresAt": 1 }, { expireAfterSeconds: 0 });
30
+ }));
31
+ return locksColl;
26
32
  });
27
33
  }
28
34
  /**
package/src/mongo-lock.ts CHANGED
@@ -9,7 +9,12 @@ export class MongoLock {
9
9
  }
10
10
 
11
11
  private async getCollection() {
12
- return this.client.db().collection('locks');
12
+ const locksColl = this.client.db().collection('locks');
13
+ await locksColl.indexExists('expiresAt')
14
+ .then(async exists => {
15
+ if (!exists) await locksColl.createIndex({"expiresAt": 1}, {expireAfterSeconds: 0});
16
+ });
17
+ return locksColl;
13
18
  }
14
19
 
15
20
  /**