---
id: "packages/active-grid/api/build-interval-where"
title: "Build interval where"
description: "buildIntervalWhere, IntervalFields: generated from the source of active-grid."
url: "/packages/active-grid/api/build-interval-where"
locale: "en"
revision: "g0mvjxwj5c-88bdbe1c:build-interval-where"
---

# Build interval where

Exported by `@workspace/active-grid`. Generated from the package source; part of [the index of every export](/packages/active-grid/api).

## Functions, hooks and constants

**buildIntervalWhere**: `(value: IntervalFilterValue, fields: IntervalFields) => Record<string, unknown> \| undefined`

Builds a Prisma-shaped `where` fragment for an {@link IntervalFilterValue}
over two numeric boundary fields. Pure and framework-neutral: it emits a
plain object (no Prisma import, no domain knowledge) that a server resolver
composes into its query.

Semantics (numeric set-relations between the row interval `[lo, hi]` and the
query range `[from, to]`, where an unset query bound means open on that side):

- `within` (containment): `lo >= from AND hi <= to` for each given bound. A
`gte`/`lte` constraint excludes a null row bound by construction, so an
open-ended row (a `null` lo or hi) never matches a closed query side. With
both bounds given this is exactly the "fully inside" rule.
- `overlap`: the row touches the range. A null row bound counts as reaching
to infinity on that side and therefore always overlaps there.

Returns `undefined` when the filter is inactive (both `from` and `to` null),
so the caller can skip it.

## Types

**IntervalFields**

```ts
interface IntervalFields {
  loField: string;
  hiField: string;
}
```

The two numeric boundary fields a row's interval is stored in.
