feat: Disable index-field validation to create index for fields that don't yet exist (#8137)

This commit is contained in:
Antoine Cormouls
2025-10-10 00:03:52 +02:00
committed by GitHub
parent f024d532f0
commit 1b2347524c
5 changed files with 69 additions and 21 deletions

View File

@@ -421,6 +421,14 @@ describe_only_db('mongo')('GridFSBucket', () => {
expect(gfsResult.toString('utf8')).toBe(twoMegabytesFile);
});
it('properly upload a file when disableIndexFieldValidation exist in databaseOptions', async () => {
const gfsAdapter = new GridFSBucketAdapter(databaseURI, { disableIndexFieldValidation: true });
const twoMegabytesFile = randomString(2048 * 1024);
await gfsAdapter.createFile('myFileName', twoMegabytesFile);
const gfsResult = await gfsAdapter.getFileData('myFileName');
expect(gfsResult.toString('utf8')).toBe(twoMegabytesFile);
});
it('properly deletes a file from GridFS', async () => {
const gfsAdapter = new GridFSBucketAdapter(databaseURI);
await gfsAdapter.createFile('myFileName', 'a simple file');