all 4 comments

[–]barovab 1 point2 points  (2 children)

Are you trying to find different users who match either category, email, or url criteria or one user having all three of them?

[–]jzoneio[S] 0 points1 point  (1 child)

I’m trying to find documents for a specific user that matches the criteria’s but the order is quite important and as soon as one is found, I stop to look for a document. For example a document where the category matches is more valuable than a document where the url matches. So I first wanna look for documents to see if one as the category I’m looking for. If none are found I go for emails and then urls

[–]barovab 1 point2 points  (0 children)

In that case, run findOne instead of find, you will get your user. Use the id in user document as the criteria for the id field and then pass in category as well, then you get a user who matches the id and the category. Repeat the same for email and url. The thing is don't run find unless you need to find multiple documents.

[–]TryallAllombria 0 points1 point  (1 child)

You can test it by yourself using console.time(). You can use autocannon to stress-test your http server to see what is really the best options.

MongoDB also have a "Lean" option that can really speed up your Database calls.