Open History to see the last commit
1---
2id: LiveQuerySnapshot
3title: LiveQuerySnapshot
4---
5
6Defined in: [packages/db/src/live-query-observer.ts:69](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L69)
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:78](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L78)
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:76](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L76)
48
49Ordered results (single row for `findOne`), or `undefined` when disabled.
50
51***
52
53### isCleanedUp
54
55```ts
56isCleanedUp: boolean;
57```
58
59Defined in: [packages/db/src/live-query-observer.ts:99](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L99)
60
61***
62
63### isEnabled
64
65```ts
66isEnabled: boolean;
67```
68
69Defined in: [packages/db/src/live-query-observer.ts:100](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L100)
70
71***
72
73### isError
74
75```ts
76isError: boolean;
77```
78
79Defined in: [packages/db/src/live-query-observer.ts:98](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L98)
80
81***
82
83### isIdle
84
85```ts
86isIdle: boolean;
87```
88
89Defined in: [packages/db/src/live-query-observer.ts:97](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L97)
90
91***
92
93### isLoading
94
95```ts
96isLoading: boolean;
97```
98
99Defined in: [packages/db/src/live-query-observer.ts:91](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L91)
100
101***
102
103### isPersistedReady
104
105```ts
106isPersistedReady: boolean;
107```
108
109Defined in: [packages/db/src/live-query-observer.ts:95](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L95)
110
111***
112
113### isReady
114
115```ts
116isReady: boolean;
117```
118
119Defined in: [packages/db/src/live-query-observer.ts:92](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L92)
120
121***
122
123### layoutRevision
124
125```ts
126layoutRevision: number;
127```
128
129Defined in: [packages/db/src/live-query-observer.ts:89](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L89)
130
131Monotonic counter bumped whenever the visible layout (the ordered key
132sequence) changes — membership, ordering, or an order-only move. Lets
133consumers detect a reorder that changed no row value (which `data`/`state`
134identity alone can't express once row values are structurally shared).
135
136It is NOT in lockstep with snapshot identity: a value-only update produces a
137new snapshot while `layoutRevision` stays put. A `layoutRevision` change
138always accompanies a new snapshot, but not vice versa.
139
140***
141
142### persistedError
143
144```ts
145persistedError: unknown;
146```
147
148Defined in: [packages/db/src/live-query-observer.ts:96](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L96)
149
150***
151
152### persistedStatus
153
154```ts
155persistedStatus: LiveQueryPersistedStatus;
156```
157
158Defined in: [packages/db/src/live-query-observer.ts:94](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L94)
159
160Persisted restore is separate from upstream/Collection readiness.
161
162***
163
164### state
165
166```ts
167state: ReadonlyMap<TKey, T> | undefined;
168```
169
170Defined in: [packages/db/src/live-query-observer.ts:74](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L74)
171
172Keyed results, or `undefined` for a disabled query.
173
174***
175
176### status
177
178```ts
179status: CollectionStatus | "disabled";
180```
181
182Defined in: [packages/db/src/live-query-observer.ts:90](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L90)