robbiblubber.org

help | login | search:  
<<

Home Page
Index

Projects

Utility Suite
Data Suite
Bad Wolf Suite
WeakWiki

User Docs

ConfigNotepad
LED
rqoon
Nuub

Code Docs

.NET
Java
PHP

robbiblubber.org

Specs
Articles

Sources















read  source  history 


= countDocuments() =
----
[[MongoDB Driver Function Reference]]


Returns the number of documents matching the filter criteria in a collection.
More information can be found in the corresponding entry of the [[https://docs.mongodb.com/manual/reference/method/db.collection.countDocuments/index.html|MongoDB Manual]].


[[[@cG

<collection>.countDocuments([<filter>[, <options>]])

]]]


**Arguments**

[[[@w

|@t0@r0@c0 <collection> | | The target collection. |
| <filter> | | A filter expression using [[https://docs.mongodb.com/manual/reference/operator/|query operators]]. |
| <options> | | A BOSN document specifying options. |

]]]


**Options**

[[[@cw

{ maxTime: <long>, limit: <long>, skip: <long>, collation: <document>, hint: <document> }
<<@f:text>>
|@t0@r0@c0 limit | | The maximum number of documents to count. |
| maxTime | | The maximum amount of time to allow the count to run. |
| skip | | The number of documents to skip before counting. |
| collation | | A document specifying the [[https://docs.mongodb.com/manual/reference/bson-type-comparison-order/#collation|collation]]. |
| hint | | A document specifying a [[https://docs.mongodb.com/manual/reference/method/db.collection.deleteMany/#ex-deletemany-hint|hint]]. |
<<@/f>>
]]]


**Return Value**

[[[@w

Returns a result set (cursor).

]]]


**Example**

[[[@cw

db.employees.countDocuments({ salary: { $gt: 700000 }});

]]]

Returns the number of documents where the salary value is greater than 700000.



----
[[Main|home]] | [[MongoDB Driver Function Reference]] | [[MongoDB Driver]]