Skip to content

Commit

Permalink
fix: mongodb 5 compatability in all mongo password methods (#1220)
Browse files Browse the repository at this point in the history
Co-authored-by: Abhishek Raj <abhishek@betatestsolutions.com>
  • Loading branch information
abhishekk-raj and Abhibetatest committed May 19, 2022
1 parent 79575f8 commit fb49d62
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-cobras-shop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@accounts/mongo-password': patch
---

MongoDB 5 compatability in all mongo-password methods
25 changes: 20 additions & 5 deletions packages/database-mongo-password/src/mongo-password.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,10 @@ export class MongoServicePassword implements DatabaseInterfaceServicePassword {
},
}
);
if ((ret.modifiedCount && ret.modifiedCount === 0) || (ret.result && ret.result.nModified === 0)) {
if (
(ret.modifiedCount && ret.modifiedCount === 0) ||
(ret.result && ret.result.nModified === 0)
) {
throw new Error('User not found');
}
}
Expand All @@ -280,7 +283,10 @@ export class MongoServicePassword implements DatabaseInterfaceServicePassword {
},
}
);
if ((ret.modifiedCount && ret.modifiedCount === 0) || (ret.result && ret.result.nModified === 0)) {
if (
(ret.modifiedCount && ret.modifiedCount === 0) ||
(ret.result && ret.result.nModified === 0)
) {
throw new Error('User not found');
}
}
Expand All @@ -302,7 +308,10 @@ export class MongoServicePassword implements DatabaseInterfaceServicePassword {
$pull: { 'services.email.verificationTokens': { address: email } },
}
);
if (ret.result.nModified === 0) {
if (
(ret.modifiedCount && ret.modifiedCount === 0) ||
(ret.result && ret.result.nModified === 0)
) {
throw new Error('User not found');
}
}
Expand All @@ -324,7 +333,10 @@ export class MongoServicePassword implements DatabaseInterfaceServicePassword {
},
}
);
if (ret.result.nModified === 0) {
if (
(ret.modifiedCount && ret.modifiedCount === 0) ||
(ret.result && ret.result.nModified === 0)
) {
throw new Error('User not found');
}
}
Expand All @@ -348,7 +360,10 @@ export class MongoServicePassword implements DatabaseInterfaceServicePassword {
},
}
);
if (ret.result.nModified === 0) {
if (
(ret.modifiedCount && ret.modifiedCount === 0) ||
(ret.result && ret.result.nModified === 0)
) {
throw new Error('User not found');
}
}
Expand Down

0 comments on commit fb49d62

Please sign in to comment.