- Stitch >
- MongoDB Atlas >
- Reference >
- MongoDB Actions
collection.count()¶
On this page
Definition¶
-
collection.
count
()¶
Return the number of documents in a collection or view that match the specified query filter.
Usage¶
Example¶
- Functions
- JavaScript SDK
- Android SDK
- iOS SDK
To call the collection.count()
action from a Function, get a collection handle with
database.collection()
then call the handle’s
count()
method.
To call the collection.count()
action from a JavaScript
SDK, use the RemoteMongoCollection.count() method.
To call the collection.count()
action from the Java/Android
SDK, use the RemoteMongoCollection.count() method.
To call the collection.count()
action from the Swift/iOS
SDK, use the RemoteMongoCollection.count() method.
Parameters¶
- Functions
- JavaScript SDK
- Android SDK
- iOS SDK
The collection.count()
action has the following form:
Parameter | Description |
---|---|
Query Filter query: <document> |
Optional. A standard MongoDB query document that specifies which documents to count. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
The count() method has the following form:
Parameter | Description |
---|---|
Query Filter query: <document> |
Optional. A standard MongoDB query document that specifies which documents to count. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
The count() method has the following form:
Parameter | Description |
---|---|
Query Filter query: <document> |
Optional. A standard MongoDB query document that specifies which documents to count. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
The count() method has the following form:
Parameter | Description |
---|---|
Query Filter query: <document> |
Optional. A standard MongoDB query document that specifies which documents to count. You can use most query selectors except for evaluation, geospatial, or bitwise selectors. Specify an empty query filter ( |
Return Value¶
- Functions
- JavaScript SDK
- Android SDK
- iOS SDK
The collection.count()
action returns a Promise that
resolves to the integer number of documents in the collection
that match the query filter.
The RemoteMongoCollection.count() method returns a Promise that resolves to the integer number of documents in the collection that match the query filter.
The RemoteMongoCollection.count() method returns a Task that resolves to the integer number of documents in the collection that match the query filter.
The RemoteMongoCollection.count() method returns a StitchResult enum that resolves to the integer number of documents in the collection that match the query filter.
Value | Description |
---|---|
Count Result numDocs: <integer> numDocs: <integer> numDocs: <Long> numDocs: <Int> |
The number of documents in the collection that match the provided query filter. |