Skip to content

Commit 5d2b9aa

Browse files
committed
bring back WriteConcern keys array
1 parent f3424be commit 5d2b9aa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/operations/connect.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { MongoClient } from '../mongo_client';
1414
import { ConnectionOptions, Connection } from '../cmap/connection';
1515
import type { AuthMechanism } from '../cmap/auth/defaultAuthProviders';
1616
import { Server } from '../sdam/server';
17+
import { WRITE_CONCERN_KEYS } from '../write_concern';
1718

1819
const VALID_AUTH_MECHANISMS = new Set([
1920
'DEFAULT',
@@ -563,8 +564,7 @@ function transformUrlOptions(connStrOptions: any) {
563564

564565
// Any write concern options from the URL will be top-level, so we manually
565566
// move them options under `object.writeConcern`
566-
const wcKeys = ['w', 'wtimeout', 'j', 'journal', 'fsync'];
567-
for (const key of wcKeys) {
567+
for (const key of WRITE_CONCERN_KEYS) {
568568
if (connStrOpts[key] !== undefined) {
569569
if (connStrOpts.writeConcern === undefined) connStrOpts.writeConcern = {};
570570
connStrOpts.writeConcern[key] = connStrOpts[key];

src/write_concern.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export interface WriteConcernSettings {
2323
fsync?: boolean | 1;
2424
}
2525

26+
export const WRITE_CONCERN_KEYS = ['w', 'wtimeout', 'j', 'journal', 'fsync'];
27+
2628
/**
2729
* A MongoDB WriteConcern, which describes the level of acknowledgement
2830
* requested from MongoDB for write operations.

0 commit comments

Comments
 (0)