Skip to content

Commit ed0868f

Browse files
committed
small cleanup
1 parent 8f23776 commit ed0868f

File tree

6 files changed

+19
-15
lines changed

6 files changed

+19
-15
lines changed

src/cmap/wire_protocol/command.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ import type { WriteConcernOptions } from '../../write_concern';
1212
import type { WriteCommandOptions } from './write_command';
1313

1414
/** @internal */
15-
// FIXME: NODE-2781
1615
export interface CommandOptions extends BSONSerializeOptions, WriteConcernOptions {
16+
// FIXME: NODE-2781
17+
1718
command?: boolean;
1819
slaveOk?: boolean;
1920
/** Specify read preference if command supports it */

src/gridfs-stream/upload.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,11 @@ function doWrite(
515515
function getWriteOptions(stream: GridFSBucketWriteStream): WriteConcernOptions {
516516
const obj: WriteConcernOptions = {};
517517
if (stream.writeConcern) {
518-
obj.writeConcern = { w: stream.writeConcern.w };
519-
obj.writeConcern.wtimeout = stream.writeConcern.wtimeout;
520-
obj.writeConcern.j = stream.writeConcern.j;
518+
obj.writeConcern = {
519+
w: stream.writeConcern.w,
520+
wtimeout: stream.writeConcern.wtimeout,
521+
j: stream.writeConcern.j
522+
};
521523
}
522524
return obj;
523525
}

src/mongo_client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ export interface MongoURIOptions {
127127
retryWrites?: boolean;
128128
/** Allow a driver to force a Single topology type with a connection string containing one host */
129129
directConnection?: boolean;
130-
// TODO: but now mongo client options accept these at the top level...
131130
/** The journal write concern */
132131
journal?: boolean;
133132
/** The write concern */

src/operations/connect.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,23 +552,26 @@ function transformUrlOptions(connStrOptions: any) {
552552
connStrOpts.readConcern = new ReadConcern(connStrOpts.readConcernLevel);
553553
}
554554

555+
if (connStrOpts.wTimeoutMS) {
556+
connStrOpts.wtimeout = connStrOpts.wTimeoutMS;
557+
connStrOpts.wTimeoutMS = undefined;
558+
}
559+
555560
if (connStrOptions.srvHost) {
556561
connStrOpts.srvHost = connStrOptions.srvHost;
557562
}
558563

559-
const wc_keys = ['w', 'j', 'journal', 'wtimeout', 'wtimeoutMS', 'fsync'];
560-
const writeConcern = connStrOpts.writeConcern ?? {};
561-
for (const key of wc_keys) {
564+
// Any write concern options from the URL will be top-level, so we manually
565+
// move them options under `object.writeConcern`
566+
const wcKeys = ['w', 'wtimeout', 'j', 'journal', 'fsync'];
567+
for (const key of wcKeys) {
562568
if (connStrOpts[key] !== undefined) {
563-
writeConcern[key] = connStrOpts[key];
569+
if (connStrOpts.writeConcern === undefined) connStrOpts.writeConcern = {};
570+
connStrOpts.writeConcern[key] = connStrOpts[key];
564571
connStrOpts[key] = undefined;
565572
}
566573
}
567-
connStrOpts.writeConcern = writeConcern;
568574

569-
if (connStrOpts.writeConcern.wTimeoutMS) {
570-
connStrOpts.writrConcern.wtimeout = connStrOpts.writeConcern.wTimeoutMS;
571-
}
572575
return connStrOpts;
573576
}
574577

src/write_concern.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export class WriteConcern {
8888
) {
8989
return new WriteConcern(w, wtimeout ?? wtimeoutMS, j ?? journal, fsync);
9090
}
91-
9291
return undefined;
9392
}
9493
}

test/tools/runner/config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class NativeConfiguration {
3333
);
3434

3535
this.writeConcern = function () {
36-
return { writeConcern: { w: 1 } }; //TODO HANA
36+
return { writeConcern: { w: 1 } };
3737
};
3838
}
3939

0 commit comments

Comments
 (0)