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

parseOrderByExpression.md

36 lines836 Bytes

1---
2id: parseOrderByExpression
3title: parseOrderByExpression
4---
5​
6```ts
7function parseOrderByExpression(orderBy): ParsedOrderBy[];
8```
9​
10Defined in: [packages/db/src/query/expression-helpers.ts:270](https://github.com/TanStack/db/blob/main/packages/db/src/query/expression-helpers.ts#L270)
11​
12Parses an ORDER BY expression into a simple array of sort specifications.
13​
14## Parameters
15​
16### orderBy
17​
18The ORDER BY expression array
19​
20[`OrderBy`](../@tanstack/namespaces/IR/type-aliases/OrderBy.md) | `null` | `undefined`
21​
22## Returns
23​
24[`ParsedOrderBy`](../interfaces/ParsedOrderBy.md)[]
25​
26Array of parsed order by specifications
27​
28## Example
29​
30```typescript
31const sorts = parseOrderByExpression(orderBy)
32// Returns: [
33// { field: ['category'], direction: 'asc', nulls: 'last' },
34// { field: ['price'], direction: 'desc', nulls: 'last' }
35// ]
36```