Actions18
- Auth Actions
- Collection Actions
- Global Actions
Overview
This node interacts with Payload CMS collections to perform various operations, including counting documents within a specified collection. It is useful for scenarios where you need to retrieve the number of documents that match certain criteria in a Payload CMS collection, such as for reporting, analytics, or conditional workflows. For example, you can count how many blog posts meet specific filter conditions or how many user records exist in a collection.
Use Case Examples
- Count the number of documents in a 'posts' collection where the status is 'published'.
- Retrieve the total count of users in a 'users' collection for monitoring user base growth.
Properties
| Name | Meaning |
|---|---|
| Collection | The specific Payload CMS collection to operate on, e.g., 'posts' or 'users'. |
| Additional Options | Optional parameters to refine the count operation, including depth of relationship population, pagination (limit and page), sorting, filtering (where clause), field selection, and locale for localized content. |
Output
JSON
json- The JSON response from Payload CMS containing the count of documents matching the criteria.
Dependencies
- Requires an API key credential for Payload CMS to authenticate requests.
Troubleshooting
- Ensure the Payload CMS instance is accessible and the API credentials are valid to avoid authentication errors.
- If the 'where' JSON filter is malformed, parsing errors may occur; ensure valid JSON format.
- Pagination parameters (limit and page) should be set correctly to avoid unexpected results or empty counts.
Links
- Payload CMS Collections API - Count - Official documentation for counting documents in Payload CMS collections.