From 5d2b9aa7ecff630e7770b9a1b1751f11b7d82d52 Mon Sep 17 00:00:00 2001 From: Neal Beeken Date: Fri, 4 Dec 2020 10:40:26 -0500 Subject: [PATCH] bring back WriteConcern keys array --- src/operations/connect.ts | 4 ++-- src/write_concern.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/operations/connect.ts b/src/operations/connect.ts index d1d44a19e5b..b8afbffee9f 100644 --- a/src/operations/connect.ts +++ b/src/operations/connect.ts @@ -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', @@ -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]; diff --git a/src/write_concern.ts b/src/write_concern.ts index 52a70738fb2..bba5e505477 100644 --- a/src/write_concern.ts +++ b/src/write_concern.ts @@ -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.