diff options
| author | UMTS at Teleco <crt@teleco.ch> | 2026-02-15 15:53:50 +0100 |
|---|---|---|
| committer | UMTS at Teleco <crt@teleco.ch> | 2026-02-15 15:53:50 +0100 |
| commit | fa680b24d1123f9de27fc752943e43c86c692314 (patch) | |
| tree | e4875712a0f8298819c490dc42e881218a2175bc /query/count.md | |
JAYSON DERULO
Diffstat (limited to 'query/count.md')
| -rw-r--r-- | query/count.md | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/query/count.md b/query/count.md new file mode 100644 index 0000000..bb4e14d --- /dev/null +++ b/query/count.md @@ -0,0 +1,48 @@ +# Count + +[back to query](README.md) /// [home](../README.md) + +Count rows matching a filter. Like select but just gives you the number in data field. + +## Request + +```json +{ + "action": "count", + "table": "items", + "filter": { + "column": "status", + "op": "=", + "value": "active" + } +} +``` + +## Fields + +| Field | Type | Required | Notes | +|----------|--------|----------|-----------------------------| +| `action` | string | yes | must be `"count"` | +| `table` | string | yes | target table | +| `where` | object | no | simple key value filter | +| `filter` | object | no | structured filter | +| `joins` | array | no | join other tables if needed | + +No limit or offset for count, it always counts everything that matches. + +## Response + +```json +{ + "success": true, + "data": 42 +} +``` + +`data` is just the count as a number. + +## Behaviors + +- should support joins so you can count rows with conditions on related tables +- ownership scoping should apply: if you have `rwo` or `rwg` the count should only include rows you have access to +- you need at least read permission on the table |
