I wanted to share an important observation related to a previous issue I mentioned. When using the following command:
const { filters } = await db.command({ planCacheListFilters: 'test', readPreference: 'secondary' });
I noticed that the MongoDB driver did not throw any errors, such as syntax errors, even though the command did not behave as expected. This behaviour could potentially be misleading, as it may appear that the command is valid.
After further investigation, I found that to ensure the desired behaviour, it’s necessary to specify the ‘readPreference’ both in the connection string and in the command itself, as shown below:
const { filters } = await db.command({ planCacheListFilters: 'test' }, { readPreference: 'secondary' });