toOrdering() function
Turn a wire ordering into the callbacks .orderBy() takes.
Signature:
export declare function toOrdering(orderBy: OrderBy | undefined): ((fields: Fields) => unknown)[];
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
orderBy |
OrderBy | undefined |
The ordering, or undefined for none. |
Returns:
((fields: Fields) => unknown)[]
One callback per key, in order; empty when nothing orders it.
Remarks
One callback per sort key, because .orderBy() accepts a single item and additional keys are expressed by chaining it. Returning an array from the callback instead fails deep inside parameter collection with an unrecognisable error, so the shape is pinned here rather than left to a caller to rediscover.
Example
toOrdering({ createdAt: 'desc', id: 'asc' }).reduce(
(query, by) => query.orderBy(by),
db.orm.public.Session,
);
Read this page as plain markdown — no HTML, no navigation. For pasting into an LLM, or for an agent to fetch.