You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This also works with joins to derive collections from multiple source collections. And it works recursively -- you can derive collections from other derived collections. Changes propagate efficiently using differential dataflow and it's collections all the way down.
@@ -378,14 +377,18 @@ Use the `useLiveQuery` hook to assign live query results to a state variable in
378
377
379
378
```ts
380
379
import { useLiveQuery } from'@tanstack/react-db'
380
+
import { eq } from'@tanstack/db'
381
381
382
382
const Todos = () => {
383
-
const { data: todos } =useLiveQuery(query=>
384
-
query
385
-
.from({ todoCollection })
386
-
.where('@completed', '=', false)
387
-
.orderBy({'@created_at': 'asc'})
388
-
.select('@id', '@text')
383
+
const { data: todos } =useLiveQuery((q) =>
384
+
q
385
+
.from({ todo: todoCollection })
386
+
.where(({ todo }) =>eq(todo.completed, false))
387
+
.orderBy(({ todo }) =>todo.created_at, 'asc')
388
+
.select(({ todo }) => ({
389
+
id: todo.id,
390
+
text: todo.text
391
+
}))
389
392
)
390
393
391
394
return <Listitems={ todos } />
@@ -396,18 +399,23 @@ You can also query across collections with joins:
0 commit comments