@tanstack/vue-db 0.0.113 → 0.0.115

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/vue-db",
3
- "version": "0.0.113",
3
+ "version": "0.0.115",
4
4
  "description": "Vue integration for @tanstack/db",
5
5
  "author": "Kyle Mathews",
6
6
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "skills"
41
41
  ],
42
42
  "dependencies": {
43
- "@tanstack/db": "0.6.2"
43
+ "@tanstack/db": "0.6.4"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "vue": ">=3.3.0"
@@ -111,6 +111,74 @@ const handleToggle = (id: number) => {
111
111
  }
112
112
  ```
113
113
 
114
+ ## Includes (Hierarchical Data)
115
+
116
+ 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:
117
+
118
+ ```vue
119
+ <!-- ProjectList.vue -->
120
+ <script setup lang="ts">
121
+ import { useLiveQuery, eq } from '@tanstack/vue-db'
122
+
123
+ const { data: projects } = useLiveQuery((q) =>
124
+ q.from({ p: projectsCollection }).select(({ p }) => ({
125
+ id: p.id,
126
+ name: p.name,
127
+ issues: q
128
+ .from({ i: issuesCollection })
129
+ .where(({ i }) => eq(i.projectId, p.id))
130
+ .select(({ i }) => ({ id: i.id, title: i.title })),
131
+ })),
132
+ )
133
+ </script>
134
+
135
+ <template>
136
+ <div v-for="project in projects" :key="project.id">
137
+ {{ project.name }}
138
+ <IssueList :issues-collection="project.issues" />
139
+ </div>
140
+ </template>
141
+ ```
142
+
143
+ ```vue
144
+ <!-- IssueList.vue — subscribes to the child Collection -->
145
+ <script setup lang="ts">
146
+ import { useLiveQuery } from '@tanstack/vue-db'
147
+ import type { Collection } from '@tanstack/db'
148
+
149
+ const props = defineProps<{ issuesCollection: Collection }>()
150
+ const { data: issues } = useLiveQuery(() => props.issuesCollection)
151
+ </script>
152
+
153
+ <template>
154
+ <ul>
155
+ <li v-for="issue in issues" :key="issue.id">{{ issue.title }}</li>
156
+ </ul>
157
+ </template>
158
+ ```
159
+
160
+ With `toArray()`, child results are plain arrays and the parent re-emits on child changes:
161
+
162
+ ```ts
163
+ import { toArray, eq } from '@tanstack/vue-db'
164
+
165
+ const { data: projects } = useLiveQuery((q) =>
166
+ q.from({ p: projectsCollection }).select(({ p }) => ({
167
+ id: p.id,
168
+ name: p.name,
169
+ issues: toArray(
170
+ q
171
+ .from({ i: issuesCollection })
172
+ .where(({ i }) => eq(i.projectId, p.id))
173
+ .select(({ i }) => ({ id: i.id, title: i.title })),
174
+ ),
175
+ })),
176
+ )
177
+ // project.issues is a plain array — no subcomponent needed
178
+ ```
179
+
180
+ See db-core/live-queries/SKILL.md for full includes rules (correlation conditions, nested includes, aggregates).
181
+
114
182
  ## Common Mistakes
115
183
 
116
184
  ### CRITICAL Missing reactive deps in dependency array