API/PostgrestResponseStrategy
PostgrestResponseStrategy
src/strategies/postgrest-response.strategy.ts1 public methodsclass
Response strategy for the PostgREST driver
PostgREST (and Supabase, which wraps it) returns a bare array body for
collection endpoints. Pagination metadata is carried in the
Content-Range HTTP response header, e.g. 0-9/50 meaning “items 0–9
out of 50 total”. Consumers opt into totals by sending the
Prefer: count=exact request header.
This strategy expects the consumer to pass the array body as response
(or a plain object with readPath(response, options.data) pointing at the array)
and the response headers via the optional headers bag. See
PaginationService.paginate() for the call-site shape.
Constructor
Section titled “Constructor”new PostgrestResponseStrategy()Methods
Section titled “Methods”paginate()
Section titled “paginate()”paginate(response: RawResponse, options: ResponseOptions, headers?: HeaderBag): PaginatedCollection<T>Parse a PostgREST response into a typed PaginatedCollection
| Parameter | Type | Description |
|---|---|---|
response |
RawResponse |
The raw response. Either the array body directly, or an object with the array at readPath(response, options.data). |
options |
ResponseOptions |
The response key configuration (only options.data is consulted; all pagination metadata comes from the Content-Range header). |
headers |
HeaderBag |
Optional HTTP response headers. The Content-Range header drives page/total derivation; omission is tolerated and yields a collection with undefined bounds (auto-sync will leave isLastPageKnown at false). |
Returns — A typed PaginatedCollection instance
