Commit f795a67
Add helper to extract the result type from a query
* feat(db): Export ExtractContext type for extracting query result types
This allows users to extract the result type from a Query instance:
```typescript
import { Query, ExtractContext, GetResult } from '@tanstack/db'
const myQuery = new Query()
.from({ users })
.select(({ users }) => ({ name: users.name }))
type MyQueryResult = GetResult<ExtractContext<typeof myQuery>>
```
Fixes a gap in the public API where ExtractContext was defined but
not re-exported from the main query module.
* chore: Add changeset for ExtractContext export
* feat(db): Add QueryResult helper type for extracting query result types
Adds a simpler API similar to Zod's z.infer:
```typescript
import { Query, QueryResult } from '@tanstack/db'
const myQuery = new Query()
.from({ users })
.select(({ users }) => ({ name: users.name }))
type MyQueryResult = QueryResult<typeof myQuery>
```
This is more ergonomic than the two-step approach:
`GetResult<ExtractContext<typeof myQuery>>`
---------
Co-authored-by: Claude <[email protected]>QueryResult (#1096)1 parent b1cc4a7 commit f795a67
3 files changed
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
887 | 888 | | |
888 | 889 | | |
889 | 890 | | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
890 | 894 | | |
891 | 895 | | |
892 | 896 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
0 commit comments