Patch Changes
-
Add
findOne()/SingleResultsupport touseLiveQueryhook. (#1001)When using
.findOne()in a query, thedataproperty is now correctly typed asT | undefinedinstead ofArray<T>, matching the React implementation.Example:
const query = useLiveQuery((q) => q .from({ users: usersCollection }) .where(({ users }) => eq(users.id, userId)) .findOne(), ) // query.data is now typed as User | undefined (not User[])
This works with all query patterns:
- Query functions:
useLiveQuery((q) => q.from(...).findOne()) - Config objects:
useLiveQuery({ query: (q) => q.from(...).findOne() }) - Pre-created collections with
SingleResult
- Query functions:
-
Updated dependencies [
f795a67,d542667,6503c09,b1cc4a7]:- @tanstack/db@0.5.17