WayrApp Backend & Ecosystem Documentation - v1.0.0
    Preparing search index...

    Function buildRangeFilter

    • 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

      // Date range filter
      const dateFilter = buildRangeFilter('createdAt', '2024-01-01', '2024-12-31');
      // Returns: { createdAt: { gte: '2024-01-01', lte: '2024-12-31' } }
      // Price range with only minimum
      const priceFilter = buildRangeFilter('price', 100);
      // Returns: { price: { gte: 100 } }
      // No bounds returns empty object
      const emptyFilter = buildRangeFilter('price');
      // Returns: {}