Skip to content

Commit

Permalink
chore(deps): update mongodb to v4.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-abbott committed Jun 23, 2022
1 parent 7e3eb4e commit 9583f3f
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 75 deletions.
184 changes: 115 additions & 69 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
},
"dependencies": {
"lodash": "4.17.21",
"mongodb": "4.1.3",
"mongodb": "4.7.0",
"type-check": "0.4.0"
},
"jest": {
Expand Down
20 changes: 15 additions & 5 deletions src/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@
*/

import * as _ from 'lodash';
import { Collection, Db, MongoClient, MongoClientOptions } from 'mongodb';
import {
Collection,
Db,
MongoClient,
MongoClientOptions,
ObjectId,
} from 'mongodb';
import { typeCheck } from 'type-check';
const check = typeCheck;

Expand Down Expand Up @@ -66,6 +72,7 @@ export interface Migration {
}

export class Migrator {
private migratorKey = 'control' as unknown as ObjectId;
private defaultMigration = {
down: (_db: Db) => Promise.reject(`Can't go down from default`),
name: 'default',
Expand Down Expand Up @@ -246,7 +253,10 @@ export class Migrator {
* @memberof Migration
*/
public unlock(): void {
this.collection.updateOne({ _id: 'control' }, { $set: { locked: false } });
this.collection.updateOne(
{ _id: this.migratorKey },
{ $set: { locked: false } }
);
}

/**
Expand Down Expand Up @@ -284,7 +294,7 @@ export class Migrator {
*/
const updateResult = await self.collection.findOneAndUpdate(
{
_id: 'control',
_id: this.migratorKey,
locked: false,
},
{
Expand Down Expand Up @@ -421,7 +431,7 @@ export class Migrator {
* @memberof Migration
*/
private async getControl(): Promise<MigrationControl> {
const con = await this.collection.findOne({ _id: 'control' });
const con = await this.collection.findOne({ _id: this.migratorKey });
return (
con ||
(await this.setControl({
Expand Down Expand Up @@ -449,7 +459,7 @@ export class Migrator {

const updateResult = await this.collection.updateOne(
{
_id: 'control',
_id: this.migratorKey,
},
{
$set: {
Expand Down

0 comments on commit 9583f3f

Please sign in to comment.