-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify best practices for countDocuments() and estimatedDocumentCount() #6745
Comments
I agree with this issue, I don't understand why I have to switch between two functions. |
There's some more detail about why you would use one vs the other in the API docs:
TLDR; |
use count(0) instead of count({filter}) or countDocument({filter}) to run estimatedDocumentCount() |
Is it the best practice to use estimatedDocumentCount() when there is no query parameter? |
@libook yes, you should use estimatedDocumentCount when there's no filter param. There may be some reasons to use countDocumenta() if you're using sharding, but I'm not certain. |
CountDocuments |
Re: discussion from #6713, leaving a note to think about whether we should add a method that switches between
countDocuments()
andestimatedDocumentCount()
based on whetherfilter
is empty or not.The text was updated successfully, but these errors were encountered: