Returning total for paginated searching

How can we return the of total number of documents returned in a mongodb atlas search when it is being paginated.

For example, If we have 11 matching results when doing the search, but pagination should show 10 results per page. when using the limit argument it will only return 10 documents, but we need to return the total number of results matched (11) during the search as well.


Do you mean the db.find() operation? If so you can append a .count() to get the total: db.mycol.find({...}).count();
If you mean the $search in the Mongo Atlas views then you probably can add a $count stage to the aggregation pipeline when executed from your application.