Performance of find & project vs findOne and then grabbing the property on the result

I need just one property of one document.

I see that I can’t .project after .findOne, only after .find.

I’m concerned about the data egress (although it is small) and the performance of the request.

With my understanding of how MongoDB queries a collection - once it finds a satisfying record in findOne it immediately returns. But using find, it needs to search through the whole collection - right?

If it matters, I am searching on _id (a single _id), so since I’m searching on an index, how would it affect the performance to use find (and then I can use project) vs findOne.

On the other hand, the size of the full document which would be returned from the findOne query is very small.

So I’m just not sure which is best. Thanks for any help.

Edit to add: Digging around, I found the findOptions and set the limit to 1 (and went ahead and just used the project in the findOptions). I think this will work well for me.

No it doesn’t if you have the right index backing the query (although it also depends on what your query is). See Create Indexes to Support Your Queries

As you have discovered, findOne() is basically a shorthand to do a find() with limit 1, execute the cursor, and return the single document. See this line in particular for the Node driver for the actual implementation.

In contrast, find() returns a cursor. The query is not executed until you act on the cursor.

Best regards
Kevin