From bf1c93b31e9f8f8acd6c586760f925baf75c4507 Mon Sep 17 00:00:00 2001 From: Tom Wilson Date: Tue, 10 Oct 2023 09:36:35 -0600 Subject: [PATCH] bugfix: delete enableSchemaHooks as an option before passing database options into file adapter --- spec/helper.js | 3 +++ src/Controllers/index.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/helper.js b/spec/helper.js index f769c0f521..ef4a2adbbd 100644 --- a/spec/helper.js +++ b/spec/helper.js @@ -61,6 +61,9 @@ if (process.env.PARSE_SERVER_TEST_DB === 'postgres') { databaseAdapter = new MongoStorageAdapter({ uri: mongoURI, collectionPrefix: 'test_', + mongoOptions: { + enableSchemaHooks: true, + } }); } diff --git a/src/Controllers/index.js b/src/Controllers/index.js index 0a9b3db57d..4a417ae9a3 100644 --- a/src/Controllers/index.js +++ b/src/Controllers/index.js @@ -104,7 +104,10 @@ export function getFilesController(options: ParseServerOptions): FilesController throw 'When using an explicit database adapter, you must also use an explicit filesAdapter.'; } const filesControllerAdapter = loadAdapter(filesAdapter, () => { - return new GridFSBucketAdapter(databaseURI, databaseOptions, fileKey); + const newDatabaseOptions = { ...databaseOptions }; + // enableSchemaHooks is not a valid mongodb option + delete newDatabaseOptions.enableSchemaHooks; + return new GridFSBucketAdapter(databaseURI, newDatabaseOptions, fileKey); }); return new FilesController(filesControllerAdapter, appId, { preserveFileName,