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 +1 -1
- package/src/mongo-lock.js +7 -1
- package/src/mongo-lock.ts +6 -1
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
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
|
/**
|