Query.prototype.estimatedDocumentCount()
Parameters
[options] «Object» passed transparently to the MongoDB driver
[callback] «Function» optional params are (error, count)
Returns:
- «Query» this
Specifies this query as a estimatedDocumentCount()
query. Faster than using countDocuments()
for large collections because estimatedDocumentCount()
uses collection metadata rather than scanning the entire collection.
estimatedDocumentCount()
does not accept a filter. Model.find({ foo: bar }).estimatedDocumentCount()
is equivalent to Model.find().estimatedDocumentCount()
This function triggers the following middleware.
estimatedDocumentCount()
Example:
await Model.find().estimatedDocumentCount();
当前内容版权归 mongoosejs 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 mongoosejs .