Open History to see the last commit
1---
2id: LiveQuerySnapshot
3title: LiveQuerySnapshot
4---
5
6Defined in: [packages/db/src/live-query-observer.ts:23](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L23)
7
8The canonical, adapter-agnostic view of a live query at a point in time.
9
10`getSnapshot()` returns a stable object identity that only changes when the
11query changes, so `useSyncExternalStore`-style consumers can compare by
12reference. Each snapshot owns a captured view of `state`/`data`, so reading
13an older snapshot cannot expose rows from a later revision.
14
15## Type Parameters
16
17### T
18
19`T` *extends* `object`
20
21### TKey
22
23`TKey` *extends* `string` \| `number`
24
25## Properties
26
27### collection
28
29```ts
30collection:
31 | Collection<T, TKey, any, StandardSchemaV1<unknown, unknown>, T>
32 | undefined;
33```
34
35Defined in: [packages/db/src/live-query-observer.ts:32](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L32)
36
37The underlying collection, or `undefined` when disabled.
38
39***
40
41### data
42
43```ts
44data: T | readonly T[] | undefined;
45```
46
47Defined in: [packages/db/src/live-query-observer.ts:30](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L30)
48
49Ordered results (single row for `findOne`), or `undefined` when disabled.
50
51***
52
53### health
54
55```ts
56health: HealthNode | undefined;
57```
58
59Defined in: [packages/db/src/live-query-observer.ts:64](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L64)
60
61The health tree for the query and every Collection it depends on, or
62`undefined` for a disabled query. After the first ready, a source
63problem shows here and the data stays.
64
65***
66
67### isCleanedUp
68
69```ts
70isCleanedUp: boolean;
71```
72
73Defined in: [packages/db/src/live-query-observer.ts:52](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L52)
74
75***
76
77### isCrashed
78
79```ts
80isCrashed: boolean;
81```
82
83Defined in: [packages/db/src/live-query-observer.ts:51](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L51)
84
85Local storage or an invariant broke. Only a cascade cleanup and a fresh start recover.
86
87***
88
89### isEnabled
90
91```ts
92isEnabled: boolean;
93```
94
95Defined in: [packages/db/src/live-query-observer.ts:53](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L53)
96
97***
98
99### isIdle
100
101```ts
102isIdle: boolean;
103```
104
105Defined in: [packages/db/src/live-query-observer.ts:47](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L47)
106
107***
108
109### isLoading
110
111```ts
112isLoading: boolean;
113```
114
115Defined in: [packages/db/src/live-query-observer.ts:45](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L45)
116
117***
118
119### isLoadingError
120
121```ts
122isLoadingError: boolean;
123```
124
125Defined in: [packages/db/src/live-query-observer.ts:49](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L49)
126
127The first load failed: there is nothing to show.
128
129***
130
131### isReady
132
133```ts
134isReady: boolean;
135```
136
137Defined in: [packages/db/src/live-query-observer.ts:46](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L46)
138
139***
140
141### isSyncError
142
143```ts
144isSyncError: boolean;
145```
146
147Defined in: [packages/db/src/live-query-observer.ts:58](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L58)
148
149The data is shown, and something keeps it from staying current: a sync
150problem or a failed request somewhere in `health`.
151
152***
153
154### layoutRevision
155
156```ts
157layoutRevision: number;
158```
159
160Defined in: [packages/db/src/live-query-observer.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L43)
161
162Monotonic counter bumped whenever the visible layout (the ordered key
163sequence) changes — membership, ordering, or an order-only move. Lets
164consumers detect a reorder that changed no row value (which `data`/`state`
165identity alone can't express once row values are structurally shared).
166
167It is NOT in lockstep with snapshot identity: a value-only update produces a
168new snapshot while `layoutRevision` stays put. A `layoutRevision` change
169always accompanies a new snapshot, but not vice versa.
170
171***
172
173### state
174
175```ts
176state: ReadonlyMap<TKey, T> | undefined;
177```
178
179Defined in: [packages/db/src/live-query-observer.ts:28](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L28)
180
181Keyed results, or `undefined` for a disabled query.
182
183***
184
185### status
186
187```ts
188status: CollectionStatus | "disabled";
189```
190
191Defined in: [packages/db/src/live-query-observer.ts:44](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L44)