Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

isOffsetLimitSubset.md

63 lines1.5 KB

1---
2id: isOffsetLimitSubset
3title: isOffsetLimitSubset
4---
5​
6# Function: isOffsetLimitSubset()
7​
8```ts
9function isOffsetLimitSubset(subset, superset): boolean;
10```
11​
12Defined in: [packages/db/src/query/predicate-utils.ts:813](https://github.com/TanStack/db/blob/main/packages/db/src/query/predicate-utils.ts#L813)
13​
14Check if one offset+limit range is a subset of another.
15Returns true if the subset range is fully contained within the superset range.
16​
17A query with `{limit: 10, offset: 0}` loads rows [0, 10).
18A query with `{limit: 10, offset: 20}` loads rows [20, 30).
19​
20For subset to be satisfied by superset:
21- Superset must start at or before subset (superset.offset <= subset.offset)
22- Superset must end at or after subset (superset.offset + superset.limit >= subset.offset + subset.limit)
23​
24## Parameters
25​
26### subset
27​
28The offset+limit requirements to check
29​
30#### limit?
31​
32`number`
33​
34#### offset?
35​
36`number`
37​
38### superset
39​
40The offset+limit that might satisfy the requirements
41​
42#### limit?
43​
44`number`
45​
46#### offset?
47​
48`number`
49​
50## Returns
51​
52`boolean`
53​
54true if subset range is fully contained within superset range
55​
56## Example
57​
58```ts
59isOffsetLimitSubset({ offset: 0, limit: 5 }, { offset: 0, limit: 10 }) // true
60isOffsetLimitSubset({ offset: 5, limit: 5 }, { offset: 0, limit: 10 }) // true (rows 5-9 within 0-9)
61isOffsetLimitSubset({ offset: 5, limit: 10 }, { offset: 0, limit: 10 }) // false (rows 5-14 exceed 0-9)
62isOffsetLimitSubset({ offset: 20, limit: 10 }, { offset: 0, limit: 10 }) // false (rows 20-29 outside 0-9)
63```