Open History to see the last commit
1<script lang="ts">
2 import { useLiveQuery } from '../src/useLiveQuery.svelte.js'
3 import type { CollectionOptions } from '@tanstack/db'
4
5 type Person = {
6 id: string
7 name: string
8 sourcePayload: string
9 }
10
11 let {
12 descriptor,
13 }: {
14 descriptor: CollectionOptions<Person, string>
15 } = $props()
16
17 const people = useLiveQuery({
18 query: (q) =>
19 q.from({ people: descriptor }).select(({ people }) => ({
20 id: people.id,
21 name: people.name,
22 })),
23 })
24</script>
25
26<output data-status={people.status}>
27 {#each people.data as person (person.id)}
28 <span>{person.name}</span>
29 {/each}
30</output>