Not sure how to change the new code to get things working as you want, but if your old query was working except for needing too long, and you have a pro or higher account, you could try using a background function to do the slow part without changing your code otherwise, potentially:
I canāt upload to pro a project that still does not generate revenue. Is a pitty that this static site does not let me deploy a express server. Not even that a request to save data in MongoDB cant be performed in less than ten seconds by netlify serverless fuctions.
Is It the solution change this cloud computing platform for someting else (Heroku, Vercel, CloudFlare)?
As mentioned here, the problem is your slow-running query, not Netlify. If thereās no way to make MongoDB respond within the 10 second limit, Iām afraid thereās not much we can do about it.
Since we donāt know your database, or your codebase, and can never be as familiar with it as you are, we cannot provide any tips to optimise your database queries.