Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
HanaPearlman authored and nbbeeken committed Nov 30, 2020
1 parent d9e5d80 commit b4346bb
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/cmap/wire_protocol/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ import type { WriteConcernOptions } from '../../write_concern';
import type { WriteCommandOptions } from './write_command';

/** @internal */
// FIXME: NODE-2781
export interface CommandOptions extends BSONSerializeOptions, WriteConcernOptions {
// FIXME: NODE-2781

command?: boolean;
slaveOk?: boolean;
/** Specify read preference if command supports it */
Expand Down
8 changes: 5 additions & 3 deletions src/gridfs-stream/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,9 +515,11 @@ function doWrite(
function getWriteOptions(stream: GridFSBucketWriteStream): WriteConcernOptions {
const obj: WriteConcernOptions = {};
if (stream.writeConcern) {
obj.writeConcern = { w: stream.writeConcern.w };
obj.writeConcern.wtimeout = stream.writeConcern.wtimeout;
obj.writeConcern.j = stream.writeConcern.j;
obj.writeConcern = {
w: stream.writeConcern.w,
wtimeout: stream.writeConcern.wtimeout,
j: stream.writeConcern.j
};
}
return obj;
}
Expand Down
1 change: 0 additions & 1 deletion src/mongo_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ export interface MongoURIOptions {
retryWrites?: boolean;
/** Allow a driver to force a Single topology type with a connection string containing one host */
directConnection?: boolean;
// TODO: but now mongo client options accept these at the top level...
/** The journal write concern */
journal?: boolean;
/** The write concern */
Expand Down
19 changes: 11 additions & 8 deletions src/operations/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,23 +552,26 @@ function transformUrlOptions(connStrOptions: any) {
connStrOpts.readConcern = new ReadConcern(connStrOpts.readConcernLevel);
}

if (connStrOpts.wTimeoutMS) {
connStrOpts.wtimeout = connStrOpts.wTimeoutMS;
connStrOpts.wTimeoutMS = undefined;
}

if (connStrOptions.srvHost) {
connStrOpts.srvHost = connStrOptions.srvHost;
}

const wc_keys = ['w', 'j', 'journal', 'wtimeout', 'wtimeoutMS', 'fsync'];
const writeConcern = connStrOpts.writeConcern ?? {};
for (const key of wc_keys) {
// 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) {
if (connStrOpts[key] !== undefined) {
writeConcern[key] = connStrOpts[key];
if (connStrOpts.writeConcern === undefined) connStrOpts.writeConcern = {};
connStrOpts.writeConcern[key] = connStrOpts[key];
connStrOpts[key] = undefined;
}
}
connStrOpts.writeConcern = writeConcern;

if (connStrOpts.writeConcern.wTimeoutMS) {
connStrOpts.writrConcern.wtimeout = connStrOpts.writeConcern.wTimeoutMS;
}
return connStrOpts;
}

Expand Down
1 change: 0 additions & 1 deletion src/write_concern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export class WriteConcern {
) {
return new WriteConcern(w, wtimeout ?? wtimeoutMS, j ?? journal, fsync);
}

return undefined;
}
}
2 changes: 1 addition & 1 deletion test/tools/runner/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class NativeConfiguration {
);

this.writeConcern = function () {
return { writeConcern: { w: 1 } }; //TODO HANA
return { writeConcern: { w: 1 } };
};
}

Expand Down

0 comments on commit b4346bb

Please sign in to comment.