Payload CMS icon

Payload CMS

Interact with Payload CMS collections and globals

Collection → Count

AI-generated

Summary

Count documents in a selected collection, optionally filtered by where clause.

Inputs

  • collection (required) — Name of the collection to count documents in (selected from available collections).
  • additionalOptions — Optional configuration such as where clause, depth, limit, etc., applied to the request.

Output shape

A single numeric count value (e.g., {"count": 42})

The response contains the total matching document count; errors are propagated as NodeOperationError or continueOnFail payload.

Examples

Example 1: Count all documents in a collection

Select a collection, set operation to Count, leave additionalOptions empty; returns total count.

Example 2: Count documents matching a filter

Select a collection, add a where clause in Additional Options (e.g., {"status":"published"}), then run Count; returns matching count.

Example 3: Count with pagination parameters

Select a collection, optionally set limit or page in Additional Options to control the count query; still returns total count.

Links

Discussion