I see that cursor.count is deprecated.
However, I cannot seem to find what can replace it when we are using it with the type ‘FindCursor<WithId>’.
In other words, collection.estimatedDocumentCount and collection.countDocuments is not usable in this context.
I am trying to get the count of documents from a collection with a specific sort and query (find):
I really do not understand by the above and why it could matter when counting documents.
I really do not understand why you are sorting when counting documents. It could potentially be slow for no added benefits. The count will be the same with or without sorting.
You may call countDocuments with the query. So your statement should be