Skip to content

Commit e1246db

Browse files
committed
Fix wc spread at the mongoclient level remains
1 parent 92cb64c commit e1246db

File tree

2 files changed

+36
-19
lines changed

2 files changed

+36
-19
lines changed

src/connection_string.ts

+25-14
Original file line numberDiff line numberDiff line change
@@ -1199,8 +1199,10 @@ export const OPTIONS = {
11991199
target: 'writeConcern',
12001200
transform({ name, options, values: [value] }): WriteConcern {
12011201
const wc = WriteConcern.fromOptions({
1202-
...options.writeConcern,
1203-
fsync: getBoolean(name, value)
1202+
writeConcern: {
1203+
...options.writeConcern,
1204+
fsync: getBoolean(name, value)
1205+
}
12041206
});
12051207
if (!wc) throw new TypeError(`Unable to make a writeConcern from fsync=${value}`);
12061208
return wc;
@@ -1216,10 +1218,11 @@ export const OPTIONS = {
12161218
j: {
12171219
target: 'writeConcern',
12181220
transform({ name, options, values: [value] }): WriteConcern {
1219-
console.warn('j is deprecated');
12201221
const wc = WriteConcern.fromOptions({
1221-
...options.writeConcern,
1222-
journal: getBoolean(name, value)
1222+
writeConcern: {
1223+
...options.writeConcern,
1224+
journal: getBoolean(name, value)
1225+
}
12231226
});
12241227
if (!wc) throw new TypeError(`Unable to make a writeConcern from journal=${value}`);
12251228
return wc;
@@ -1229,8 +1232,10 @@ export const OPTIONS = {
12291232
target: 'writeConcern',
12301233
transform({ name, options, values: [value] }): WriteConcern {
12311234
const wc = WriteConcern.fromOptions({
1232-
...options.writeConcern,
1233-
journal: getBoolean(name, value)
1235+
writeConcern: {
1236+
...options.writeConcern,
1237+
journal: getBoolean(name, value)
1238+
}
12341239
});
12351240
if (!wc) throw new TypeError(`Unable to make a writeConcern from journal=${value}`);
12361241
return wc;
@@ -1516,7 +1521,7 @@ export const OPTIONS = {
15161521
w: {
15171522
target: 'writeConcern',
15181523
transform({ values: [value], options }) {
1519-
return WriteConcern.fromOptions({ ...options.writeConcern, w: value as W });
1524+
return WriteConcern.fromOptions({ writeConcern: { ...options.writeConcern, w: value as W } });
15201525
}
15211526
},
15221527
waitQueueTimeoutMS: {
@@ -1528,8 +1533,10 @@ export const OPTIONS = {
15281533
transform({ values: [value], options }) {
15291534
if (isRecord(value)) {
15301535
return WriteConcern.fromOptions({
1531-
...options.writeConcern,
1532-
...value
1536+
writeConcern: {
1537+
...options.writeConcern,
1538+
...value
1539+
}
15331540
});
15341541
}
15351542
throw new MongoParseError(`WriteConcern must be an object, got ${JSON.stringify(value)}`);
@@ -1539,8 +1546,10 @@ export const OPTIONS = {
15391546
target: 'writeConcern',
15401547
transform({ values: [value], options }) {
15411548
const wc = WriteConcern.fromOptions({
1542-
...options.writeConcern,
1543-
wtimeout: getUint('wtimeout', value)
1549+
writeConcern: {
1550+
...options.writeConcern,
1551+
wtimeout: getUint('wtimeout', value)
1552+
}
15441553
});
15451554
if (wc) return wc;
15461555
throw new MongoParseError(`Cannot make WriteConcern from wtimeout`);
@@ -1550,8 +1559,10 @@ export const OPTIONS = {
15501559
target: 'writeConcern',
15511560
transform({ values: [value], options }) {
15521561
const wc = WriteConcern.fromOptions({
1553-
...options.writeConcern,
1554-
wtimeoutMS: getUint('wtimeoutMS', value)
1562+
writeConcern: {
1563+
...options.writeConcern,
1564+
wtimeoutMS: getUint('wtimeoutMS', value)
1565+
}
15551566
});
15561567
if (wc) return wc;
15571568
throw new MongoParseError(`Cannot make WriteConcern from wtimeout`);

src/mongo_client.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
33
import { ChangeStream, ChangeStreamOptions } from './change_stream';
44
import { ReadPreference, ReadPreferenceModeId } from './read_preference';
55
import { MongoError, AnyError } from './error';
6-
import { WriteConcern, WriteConcernOptions, W } from './write_concern';
6+
import { WriteConcern, W, WriteConcernSettings } from './write_concern';
77
import { maybePromise, MongoDBNamespace, Callback, resolveOptions } from './utils';
88
import { deprecate } from 'util';
99
import { connect, validOptions } from './operations/connect';
@@ -134,13 +134,19 @@ export interface MongoURIOptions {
134134
// username and password in Authority section not query string.
135135
username?: string;
136136
password?: string;
137+
138+
// remove in NODE-2704
139+
fsync?: boolean;
140+
w?: W;
141+
j?: boolean;
142+
journal?: boolean;
143+
wtimeout?: number;
144+
wtimeoutMS?: number;
145+
writeConcern?: WriteConcern | WriteConcernSettings;
137146
}
138147

139148
/** @public */
140-
export interface MongoClientOptions
141-
extends WriteConcernOptions,
142-
MongoURIOptions,
143-
BSONSerializeOptions {
149+
export interface MongoClientOptions extends MongoURIOptions, BSONSerializeOptions {
144150
/** Validate mongod server certificate against Certificate Authority */
145151
sslValidate?: boolean;
146152
/** SSL Certificate store binary buffer. */

0 commit comments

Comments
 (0)