Skip to content

Commit 9c7695e

Browse files
omairvaiyaniJacobWithACapitalJ
authored andcommitted
Remove unsupported db options from mongo connection (#2)
* Remove unsupported db options from mongo connection * Add maxTimeMS to filter list
1 parent 832dda2 commit 9c7695e

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

spec/GridFSBucketStorageAdapter.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ describe_only_db('mongo')('GridFSBucket', () => {
3232

3333
const db = await gfsAdapter._connect();
3434
const status = await db.admin().serverStatus();
35+
36+
// connection will fail if unsupported keys are
37+
// passed into the mongo connection options
3538
expect(status.connections.current > 0).toEqual(true);
39+
3640
expect(db.options?.retryWrites).toEqual(true);
3741
});
3842

src/Adapters/Files/GridFSBucketAdapter.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class GridFSBucketAdapter extends FilesAdapter {
2020

2121
constructor(
2222
mongoDatabaseURI = defaults.DefaultMongoURI,
23-
mongoOptions = {},
23+
databaseOptions = {},
2424
encryptionKey = undefined
2525
) {
2626
super();
@@ -38,11 +38,11 @@ export class GridFSBucketAdapter extends FilesAdapter {
3838
useNewUrlParser: true,
3939
useUnifiedTopology: true,
4040
};
41-
const _mongoOptions = Object.assign(defaultMongoOptions, mongoOptions);
41+
const mongoOptions = { ...databaseOptions };
4242
for (const key of ['enableSchemaHooks', 'schemaCacheTtl', 'maxTimeMS']) {
43-
delete _mongoOptions[key];
43+
delete mongoOptions[key];
4444
}
45-
this._mongoOptions = _mongoOptions;
45+
this._mongoOptions = Object.assign(defaultMongoOptions, mongoOptions);
4646
}
4747

4848
_connect() {

0 commit comments

Comments
 (0)