Skip to content

Commit

Permalink
simplify write concern modification logic
Browse files Browse the repository at this point in the history
  • Loading branch information
W-A-James committed Oct 15, 2024
1 parent 6edcc1b commit be5f59c
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,18 +555,13 @@ export function resolveOptions<T extends CommandOperationOptions>(
let writeConcern = WriteConcern.fromOptions(options) ?? parent?.writeConcern;
if (writeConcern) {
if (timeoutMS != null) {
result.writeConcern = writeConcern;
} else {
const matchOptions = new Set(['wtimeout', 'wtimeoutMS']);
const writeConcernKeys = Object.keys(writeConcern);
if (writeConcernKeys.length > 2 && writeConcernKeys.some(k => !matchOptions.has(k))) {
writeConcern = WriteConcern.fromOptions({
...writeConcern,
wtimeout: undefined,
wtimeoutMS: undefined
});
}
writeConcern = WriteConcern.fromOptions({
...writeConcern,
wtimeout: undefined,
wtimeoutMS: undefined
});
}
result.writeConcern = writeConcern;
}
}

Expand Down

0 comments on commit be5f59c

Please sign in to comment.