Skip to content

Commit 3d90536

Browse files
committed
fix: grid fs adapter option
1 parent 30ec4ff commit 3d90536

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

spec/GridFSBucketStorageAdapter.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,14 @@ describe_only_db('mongo')('GridFSBucket', () => {
405405
expect(gfsResult.toString('utf8')).toBe(twoMegabytesFile);
406406
});
407407

408+
it('properly upload a file when disableIndexFieldValidation exist in databaseOptions', async () => {
409+
const gfsAdapter = new GridFSBucketAdapter(databaseURI, { disableIndexFieldValidation: true });
410+
const twoMegabytesFile = randomString(2048 * 1024);
411+
const res = await gfsAdapter.createFile('myFileName', twoMegabytesFile);
412+
expect(res._id).toBeTruthy();
413+
expect(res.filename).toEqual('myFileName');
414+
});
415+
408416
it('properly deletes a file from GridFS', async () => {
409417
const gfsAdapter = new GridFSBucketAdapter(databaseURI);
410418
await gfsAdapter.createFile('myFileName', 'a simple file');

src/Adapters/Files/GridFSBucketAdapter.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export class GridFSBucketAdapter extends FilesAdapter {
3535
useUnifiedTopology: true,
3636
};
3737
this._mongoOptions = Object.assign(defaultMongoOptions, mongoOptions);
38+
delete this._mongoOptions.disableIndexFieldValidation;
3839
}
3940

4041
_connect() {

0 commit comments

Comments
 (0)