Update MongoDB driver
This commit is contained in:
1 parent
cc885e7d04
commit
f4692faed6
12 files changed
+132
-156
No files matched your search
+3
-3
@@ -78,9 +78,9 @@ export async function acquireLock(
|
||||
value: token,
|
||||
expire: new Date(now + ttl + CLOCK_SKEW_TOLERANCE),
|
||||
},
|
||||
$currentDate: { timestamp: true },
|
||||
$currentDate: { timestamp: (true as unknown) as Date },
|
||||
},
|
||||
{ upsert: true, returnOriginal: false }
|
||||
{ upsert: true, returnDocument: "after" }
|
||||
);
|
||||
const v = r.value;
|
||||
if (Math.abs(v["timestamp"].getTime() - now) > CLOCK_SKEW_TOLERANCE)
|
||||
@@ -114,5 +114,5 @@ export async function releaseLock(
|
||||
_id: lockName,
|
||||
value: token,
|
||||
});
|
||||
if (res["result"]["n"] !== 1) throw new Error("Lock expired");
|
||||
if (res.deletedCount !== 1) throw new Error("Lock expired");
|
||||
}
|
||||
Reference in new issue
Block a user