Skip to content

Commit fd9b1f5

Browse files
committed
bring back WriteConcern keys array
1 parent f35bbd4 commit fd9b1f5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/operations/connect.ts

Lines changed: 2 additions & 2 deletions
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 { AuthMechanism, AuthMechanismId } from '../cmap/auth/defaultAuthProviders';
1616
import { Server } from '../sdam/server';
17+
import { WRITE_CONCERN_KEYS } from '../write_concern';
1718

1819
const validOptionNames = [
1920
'poolSize',
@@ -553,8 +554,7 @@ function transformUrlOptions(connStrOptions: any) {
553554

554555
// Any write concern options from the URL will be top-level, so we manually
555556
// move them options under `object.writeConcern`
556-
const wcKeys = ['w', 'wtimeout', 'j', 'journal', 'fsync'];
557-
for (const key of wcKeys) {
557+
for (const key of WRITE_CONCERN_KEYS) {
558558
if (connStrOpts[key] !== undefined) {
559559
if (connStrOpts.writeConcern === undefined) connStrOpts.writeConcern = {};
560560
connStrOpts.writeConcern[key] = connStrOpts[key];

src/write_concern.ts

Lines changed: 2 additions & 0 deletions
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)