Skip to content

Commit f78f50b

Browse files
dblythymtrezza
authored andcommitted
fix: custom database options are not passed to MongoDB GridFS (#7911)
1 parent 07d2b97 commit f78f50b

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Diff for: spec/FilesController.spec.js

+14
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ describe('FilesController', () => {
4343
done();
4444
});
4545

46+
it_only_db('mongo')('should pass databaseOptions to GridFSBucketAdapter', async () => {
47+
await reconfigureServer({
48+
databaseURI: 'mongodb://localhost:27017/parse',
49+
filesAdapter: null,
50+
databaseAdapter: null,
51+
databaseOptions: {
52+
retryWrites: true,
53+
},
54+
});
55+
const config = Config.get(Parse.applicationId);
56+
expect(config.database.adapter._mongoOptions.retryWrites).toBeTrue();
57+
expect(config.filesController.adapter._mongoOptions.retryWrites).toBeTrue();
58+
});
59+
4660
it('should create a server log on failure', done => {
4761
const logController = new LoggerController(new WinstonLoggerAdapter());
4862

Diff for: src/Controllers/index.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,20 @@ export function getLoggerController(options: ParseServerOptions): LoggerControll
9191
}
9292

9393
export function getFilesController(options: ParseServerOptions): FilesController {
94-
const { appId, databaseURI, filesAdapter, databaseAdapter, preserveFileName, fileKey } = options;
94+
const {
95+
appId,
96+
databaseURI,
97+
databaseOptions = {},
98+
filesAdapter,
99+
databaseAdapter,
100+
preserveFileName,
101+
fileKey,
102+
} = options;
95103
if (!filesAdapter && databaseAdapter) {
96104
throw 'When using an explicit database adapter, you must also use an explicit filesAdapter.';
97105
}
98106
const filesControllerAdapter = loadAdapter(filesAdapter, () => {
99-
return new GridFSBucketAdapter(databaseURI, {}, fileKey);
107+
return new GridFSBucketAdapter(databaseURI, databaseOptions, fileKey);
100108
});
101109
return new FilesController(filesControllerAdapter, appId, {
102110
preserveFileName,

0 commit comments

Comments
 (0)