Builds Prisma range filter for numeric or date fields with min/max bounds.
This utility creates a Prisma where clause for range-based filtering using
greater-than-or-equal (gte) and less-than-or-equal (lte) operators. It's
commonly used for date ranges, price ranges, or any numeric field filtering.
Parameters
field: string
Database field name to apply the range filter to
Optionalmin: string|number
Minimum value for the range (inclusive)
Optionalmax: string|number
Maximum value for the range (inclusive)
Returns {[key:string]:any}
Prisma where clause object with range conditions
Example
// Date range filter constdateFilter = buildRangeFilter('createdAt', '2024-01-01', '2024-12-31'); // Returns: { createdAt: { gte: '2024-01-01', lte: '2024-12-31' } }
Example
// Price range with only minimum constpriceFilter = buildRangeFilter('price', 100); // Returns: { price: { gte: 100 } }
Builds Prisma range filter for numeric or date fields with min/max bounds.
This utility creates a Prisma where clause for range-based filtering using greater-than-or-equal (gte) and less-than-or-equal (lte) operators. It's commonly used for date ranges, price ranges, or any numeric field filtering.