Open History to see the last commit
1---
2id: LiveQuerySnapshot
3title: LiveQuerySnapshot
4---
5
6# Interface: LiveQuerySnapshot\<T, TKey\>
7
8Defined in: [packages/db/src/live-query-observer.ts:19](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L19)
9
10The canonical, adapter-agnostic view of a live query at a point in time.
11
12`getSnapshot()` returns a stable object identity that only changes when the
13query changes, so `useSyncExternalStore`-style consumers can compare by
14reference. Each snapshot owns a captured view of `state`/`data`, so reading
15an older snapshot cannot expose rows from a later revision.
16
17## Type Parameters
18
19### T
20
21`T` *extends* `object`
22
23### TKey
24
25`TKey` *extends* `string` \| `number`
26
27## Properties
28
29### collection
30
31```ts
32collection:
33 | Collection<T, TKey, any, StandardSchemaV1<unknown, unknown>, T>
34 | undefined;
35```
36
37Defined in: [packages/db/src/live-query-observer.ts:28](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L28)
38
39The underlying collection, or `undefined` when disabled.
40
41***
42
43### data
44
45```ts
46data: T | readonly T[] | undefined;
47```
48
49Defined in: [packages/db/src/live-query-observer.ts:26](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L26)
50
51Ordered results (single row for `findOne`), or `undefined` when disabled.
52
53***
54
55### isCleanedUp
56
57```ts
58isCleanedUp: boolean;
59```
60
61Defined in: [packages/db/src/live-query-observer.ts:45](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L45)
62
63***
64
65### isEnabled
66
67```ts
68isEnabled: boolean;
69```
70
71Defined in: [packages/db/src/live-query-observer.ts:46](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L46)
72
73***
74
75### isError
76
77```ts
78isError: boolean;
79```
80
81Defined in: [packages/db/src/live-query-observer.ts:44](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L44)
82
83***
84
85### isIdle
86
87```ts
88isIdle: boolean;
89```
90
91Defined in: [packages/db/src/live-query-observer.ts:43](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L43)
92
93***
94
95### isLoading
96
97```ts
98isLoading: boolean;
99```
100
101Defined in: [packages/db/src/live-query-observer.ts:41](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L41)
102
103***
104
105### isReady
106
107```ts
108isReady: boolean;
109```
110
111Defined in: [packages/db/src/live-query-observer.ts:42](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L42)
112
113***
114
115### layoutRevision
116
117```ts
118layoutRevision: number;
119```
120
121Defined in: [packages/db/src/live-query-observer.ts:39](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L39)
122
123Monotonic counter bumped whenever the visible layout (the ordered key
124sequence) changes — membership, ordering, or an order-only move. Lets
125consumers detect a reorder that changed no row value (which `data`/`state`
126identity alone can't express once row values are structurally shared).
127
128It is NOT in lockstep with snapshot identity: a value-only update produces a
129new snapshot while `layoutRevision` stays put. A `layoutRevision` change
130always accompanies a new snapshot, but not vice versa.
131
132***
133
134### state
135
136```ts
137state: ReadonlyMap<TKey, T> | undefined;
138```
139
140Defined in: [packages/db/src/live-query-observer.ts:24](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L24)
141
142Keyed results, or `undefined` for a disabled query.
143
144***
145
146### status
147
148```ts
149status: CollectionStatus | "disabled";
150```
151
152Defined in: [packages/db/src/live-query-observer.ts:40](https://github.com/TanStack/db/blob/main/packages/db/src/live-query-observer.ts#L40)