Changelog - 2025-12-31
JSON Path Filtering & PostgreSQL Array Operators
In one line. You can filter by nested JSON fields and PostgreSQL array columns, and exclude a range, using normal repository filters.
What changed
- JSON path filtering. A
wherekey containing.or[is treated as a JSON path. - Safe numeric comparison. Comparison operators on JSON fields cast to numeric only when the value is numeric. Non-numeric values become NULL instead of causing a database error.
- Array operators.
contains,containedByandoverlapsfor PostgreSQL array columns. notBetween. Matches values outside a range.
typescript
await repo.find({
filter: {
where: {
'jValue.priority': 3,
'jValue.metadata.level': 'high',
'jValue.tags[0]': 'important',
'jValue.metadata.score': { gte: 70, lte: 90 },
'jValue.metadata.level': { ilike: '%igh%' },
}
}
});
// Array column: tags varchar(100)[]
await repo.find({ filter: { where: { tags: { contains: ['electronics', 'featured'] } } } });
await repo.find({ filter: { where: { tags: { containedBy: ['sale', 'featured', 'new'] } } } });
await repo.find({ filter: { where: { tags: { overlaps: ['sale', 'premium'] } } } });
// Scores < 40 OR > 60
await repo.find({ filter: { where: { score: { notBetween: [40, 60] } } } });| Operator | PostgreSQL | Description |
|---|---|---|
contains | @> | Array contains ALL specified elements |
containedBy | <@ | Array is a subset of the specified elements |
overlaps | && | Arrays share ANY common element |
Who is affected
- Everyone. No action needed. Existing filter queries work unchanged.
Details
- Security. JSON path components are validated against
/^[a-zA-Z_][a-zA-Z0-9_-]*$|^\d+$/to prevent SQL injection.jValue.user_id,jValue.meta-data,jValue.items[0]andjValue.nested[2].fieldare valid;jValue.field;DROP TABLEandjValue.123invalidthrow. - Array types. String arrays (
varchar[],text[],char[]) are cast totext[]on both sides. Numeric and boolean arrays need no casting. - Empty arrays.
{ contains: [] }istrue,{ containedBy: [] }matches only rows with empty arrays,{ overlaps: [] }isfalse. - See Query Operators, JSON Path Filtering and Array Column Operators.