LoaderOptions
import { LoaderOptions } from "@hyper-fetch/db"
Preview
type LoaderOptions<Row,Key,Req,Mapped,Where,Order,Cursor,Limit,ByKey,ByKeys,LoaderNotation> = {
byKey?: ByKey & (key: Key) => RequestPatch<Req>;
byKeys?: ByKeys & (keys: Key[]) => RequestPatch<Req>;
cursor?: (response: ExtractResponseType<Req>) => Cursor | null | undefined;
fixed?: Partial<Row>;
limit?: Limit & (limit: number) => RequestPatch<Req>;
notation?: LoaderNotation & Notation;
orderBy?: Order & OrderDeclaration<Row, Req>;
page?: (cursor: Cursor) => RequestPatch<Req>;
rows?: (response: ExtractResponseType<Req>) => readonly Mapped[];
serverOnly?: readonly (keyof Row & string)[];
where?: Where & WhereDeclaration<Row, Req>;
}
Structure
| Name | Type | Description |
|---|---|---|
| byKey | | Reads one row by key. A loader with it serves
|
| byKeys | | Reads several rows by key in one request. A loader with it serves
|
| fixed | | Conditions the endpoint applies on its own, such as
|
| limit | | Sends a query's limit. Declaring it makes the loader paginated. |
| notation | | How the backend writes every operator and order, so the loader sends conditions on any field |
| orderBy | | The fields the endpoint can sort by |
| serverOnly | | Fields the backend compares differently from the client, so queries on them are never answered locally |
| where | | The operators the endpoint can serve for each field |
| cursor | | Reads the next page's cursor from a response. Declaring it makes the loader paginated. |
| page | | Sends a cursor to load the page after it |
| rows | | Reads complete rows from a response, for example from a wrapped list such as
|
