Filter Spec
Define flexible, nested, and composable filters using conditions and logical groups.
Filters in Locospec define how data should be queried, constrained, and sliced. They’re used across select actions, views, scopes, and search, and support simple conditions as well as complex nested logic.
The filter system is designed to be:
- 🔄 Reusable
- 🧱 Composable
- 🔎 Deeply expressive
✅ Supported Filter Formats
Locospec supports three formats for defining filters:
1. Filter Group (nested, composable)
✅ Best for complex, nested filters ✅ Used in views, scopes, and select actions
2. Array of Conditions (flat)
✅ Flat structure, easy to parse ✅ Recommended for dynamic builders (like frontend UIs)
3. Key-Value Map (simple)
✅ Quick and readable ✅ Used in shorthand filters
🔧 Supported Operators
| Operator | Description |
|---|---|
is | Exact match (=) |
is_not | Not equal (!=) |
greater_than | Greater than (>) |
less_than | Less than (<) |
greater_than_or_equal | Greater than or equal (>=) |
less_than_or_equal | Less than or equal (<=) |
contains | Substring match (LIKE %value%) |
not_contains | Substring mismatch (NOT LIKE %value%) |
is_any_of | Value is in list (IN (...)) |
is_none_of | Value not in list (NOT IN (...)) |
is_empty | Field is null or empty |
is_not_empty | Field is not null |
📂 Definition: condition
| Key | Type | Description |
|---|---|---|
attribute | string | The field to apply the condition on |
op | string | One of the supported operators |
value | string, number, boolean, array, null | The value to compare to |
📚 Definition: filterGroup
| Key | Type | Description |
|---|---|---|
op | string | Logical operator: "and" or "or" |
conditions | array | Array of conditions or nested filter groups |