@tanstack/solid-db 0.2.16 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tanstack/solid-db",
3
- "version": "0.2.16",
3
+ "version": "0.2.18",
4
4
  "description": "Solid integration for @tanstack/db",
5
5
  "author": "Kyle Mathews",
6
6
  "license": "MIT",
@@ -37,7 +37,7 @@
37
37
  ],
38
38
  "dependencies": {
39
39
  "@solid-primitives/map": "^0.7.2",
40
- "@tanstack/db": "0.6.2"
40
+ "@tanstack/db": "0.6.4"
41
41
  },
42
42
  "peerDependencies": {
43
43
  "solid-js": ">=1.9.0"
@@ -138,6 +138,66 @@ return <Show when={userQuery()}>{(user) => <div>{user().name}</div>}</Show>
138
138
 
139
139
  `useLiveQuery` integrates with Solid's `createResource` — wrap in `<Suspense>` for loading states.
140
140
 
141
+ ## Includes (Hierarchical Data)
142
+
143
+ When a query uses includes (subqueries in `select`), each child field is a live `Collection` by default. Subscribe to it with `useLiveQuery` in a subcomponent:
144
+
145
+ ```tsx
146
+ function ProjectList() {
147
+ const projectsQuery = useLiveQuery((q) =>
148
+ q.from({ p: projectsCollection }).select(({ p }) => ({
149
+ id: p.id,
150
+ name: p.name,
151
+ issues: q
152
+ .from({ i: issuesCollection })
153
+ .where(({ i }) => eq(i.projectId, p.id))
154
+ .select(({ i }) => ({ id: i.id, title: i.title })),
155
+ })),
156
+ )
157
+
158
+ return (
159
+ <For each={projectsQuery()}>
160
+ {(project) => (
161
+ <div>
162
+ {project.name}
163
+ <IssueList issuesCollection={project.issues} />
164
+ </div>
165
+ )}
166
+ </For>
167
+ )
168
+ }
169
+
170
+ // Child component subscribes to the child Collection
171
+ function IssueList(props: { issuesCollection: Collection }) {
172
+ const issuesQuery = useLiveQuery(() => props.issuesCollection)
173
+ return <For each={issuesQuery()}>{(issue) => <div>{issue.title}</div>}</For>
174
+ }
175
+ ```
176
+
177
+ Note: wrap the child Collection in an Accessor (`() => props.issuesCollection`) to match the overload signature.
178
+
179
+ With `toArray()`, child results are plain arrays and the parent re-emits on child changes:
180
+
181
+ ```tsx
182
+ import { toArray, eq } from '@tanstack/solid-db'
183
+
184
+ const projectsQuery = useLiveQuery((q) =>
185
+ q.from({ p: projectsCollection }).select(({ p }) => ({
186
+ id: p.id,
187
+ name: p.name,
188
+ issues: toArray(
189
+ q
190
+ .from({ i: issuesCollection })
191
+ .where(({ i }) => eq(i.projectId, p.id))
192
+ .select(({ i }) => ({ id: i.id, title: i.title })),
193
+ ),
194
+ })),
195
+ )
196
+ // project.issues is a plain array — no subcomponent needed
197
+ ```
198
+
199
+ See db-core/live-queries/SKILL.md for full includes rules (correlation conditions, nested includes, aggregates).
200
+
141
201
  ## Common Mistakes
142
202
 
143
203
  ### HIGH Reading signals outside the query function