Skip to main content
MongoDB

MongoDB - Count documents

MongoDB - Count documents

Counts the number of documents in a MongoDB collection that match the given filter.


Options

Collection

Reference to the MongoDB: Select collection action the count will run on.

Filter (query)

Filter to narrow the count, for example { "status": "ativo" }. Pass {} to count every document in the collection.

Transaction (optional)

Reference to a MongoDB: Start transaction action when the operation must run inside a transaction. Optional field, available under the advanced options.

Returns

Javascript code

js
actions["action-id"].count // number of documents matching the filter (Number)

Field selection

  • count — number of documents matching the given filter (Number)

Rules and Conditions

  • The Collection and Filter fields are required.
  • The filter must be a valid JSON document in MongoDB format.
  • If no document matches the filter, the return is 0.