Overview
Filter-def supports filtering on nested object properties using dot-separated paths. This allows you to filter based on deeply nested data without flattening your entity structure.Dot Notation Syntax
Use dot-separated strings to reference nested properties:Type Safety
Nested field paths are fully type-checked using TypeScript’s type system:FieldPath<T> type generates all valid dot-separated paths for your entity:
Basic Example
Combining with All Filter Types
Nested fields work with all primitive filter types:Nested Fields in Boolean Filters
Nested fields work seamlessly in boolean filters:Adapter Support
Nested field support varies by adapter based on their underlying data model.
| Adapter | Nested Fields Support | Notes |
|---|---|---|
| In-Memory | ✅ Full support | Works with any nested JavaScript object |
| BigQuery | ✅ Full support | Uses dot notation for nested JSON/STRUCT fields |
| Drizzle | ❌ Not supported | Drizzle operates on flat table columns |
Drizzle Limitation
Drizzle filters operate on flat SQL table columns and do not support nested field paths:Workaround: Custom Filters
For nested JSON data in Drizzle, use custom filters with JSON operators:PathValue Type
ThePathValue<T, Path> utility type resolves the type at a nested path:
Deep Nesting
Filter-def supports up to 4 levels of nesting by default to avoid TypeScript instantiation depth errors:The depth limit exists only for type inference. Nested field access still works at runtime for deeper structures, but TypeScript won’t validate paths beyond 4 levels.
Null Safety
Nested field access handles null/undefined gracefully:undefined if any intermediate property is null or undefined.
Best Practices
Use Descriptive Filter Keys
Consider Flattening for SQL
If using Drizzle, consider flattening your schema:Validate Nested Paths
TypeScript validates nested paths, but be careful with dynamic paths:Next Steps
- Filter Types - All available primitive filters
- Custom Filters - Complex logic for nested data
- Type Inference - Understand TypeScript utilities