How to count the documents returned by a Mango query

久未见 提交于 2019-12-06 04:08:44

It is not really possible to retrieve the full number of documents by using the find function. By default _find is limited to 25 documents to be returned (http://docs.couchdb.org/en/2.0.0/api/database/find.html).

limit (number) – Maximum number of results returned. Default is 25. Optional

By increasing this number, the response time is increasing. Having e.g. 15.000 entries in your couch database and limiting the query to 999999 would result in a long waiting time.

Back to your question: after receiving your result set, simply run something like array.length to count your results.

CouchDB returns an object. In this object you'll find an array "docs". Just get the length of this array and you'll have the number of returned documents.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!