Skip to content

Commit

Permalink
bring back WriteConcern keys array
Browse files Browse the repository at this point in the history
  • Loading branch information
nbbeeken committed Dec 4, 2020
1 parent f3424be commit 5d2b9aa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/operations/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type { MongoClient } from '../mongo_client';
import { ConnectionOptions, Connection } from '../cmap/connection';
import type { AuthMechanism } from '../cmap/auth/defaultAuthProviders';
import { Server } from '../sdam/server';
import { WRITE_CONCERN_KEYS } from '../write_concern';

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

// Any write concern options from the URL will be top-level, so we manually
// move them options under `object.writeConcern`
const wcKeys = ['w', 'wtimeout', 'j', 'journal', 'fsync'];
for (const key of wcKeys) {
for (const key of WRITE_CONCERN_KEYS) {
if (connStrOpts[key] !== undefined) {
if (connStrOpts.writeConcern === undefined) connStrOpts.writeConcern = {};
connStrOpts.writeConcern[key] = connStrOpts[key];
Expand Down
2 changes: 2 additions & 0 deletions src/write_concern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export interface WriteConcernSettings {
fsync?: boolean | 1;
}

export const WRITE_CONCERN_KEYS = ['w', 'wtimeout', 'j', 'journal', 'fsync'];

/**
* A MongoDB WriteConcern, which describes the level of acknowledgement
* requested from MongoDB for write operations.
Expand Down

0 comments on commit 5d2b9aa

Please sign in to comment.