Open History to see the last commit
1---
2id: CollectionLike
3title: CollectionLike
4---
5
6Defined in: [packages/db/src/types.ts:15](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L15)
7
8Interface for a collection-like object that provides the necessary methods
9for the change events system to work
10
11## Extends
12
13- `Pick`\<[`Collection`](Collection.md)\<`T`, `TKey`\>, `"get"` \| `"has"` \| `"entries"` \| `"indexes"` \| `"id"` \| `"compareOptions"`\>
14
15## Type Parameters
16
17### T
18
19`T` *extends* `object` = `Record`\<`string`, `unknown`\>
20
21### TKey
22
23`TKey` *extends* `string` \| `number` = `string` \| `number`
24
25## Properties
26
27### compareOptions
28
29```ts
30compareOptions: StringCollationConfig;
31```
32
33Defined in: [packages/db/src/collection/index.ts:844](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L844)
34
35#### Inherited from
36
37[`CollectionImpl`](../classes/CollectionImpl.md).[`compareOptions`](../classes/CollectionImpl.md#compareoptions)
38
39***
40
41### id
42
43```ts
44id: string;
45```
46
47Defined in: [packages/db/src/collection/index.ts:390](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L390)
48
49#### Inherited from
50
51[`CollectionImpl`](../classes/CollectionImpl.md).[`id`](../classes/CollectionImpl.md#id)
52
53***
54
55### indexes
56
57```ts
58indexes: Map<number, BaseIndex<TKey>>;
59```
60
61Defined in: [packages/db/src/collection/index.ts:829](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L829)
62
63#### Inherited from
64
65```ts
66Pick.indexes
67```
68
69## Methods
70
71### entries()
72
73```ts
74entries(): IterableIterator<[TKey, WithVirtualProps<T, TKey>]>;
75```
76
77Defined in: [packages/db/src/collection/index.ts:720](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L720)
78
79Get all entries (virtual derived state)
80
81#### Returns
82
83`IterableIterator`\<\[`TKey`, [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>\]\>
84
85#### Inherited from
86
87```ts
88Pick.entries
89```
90
91***
92
93### get()
94
95```ts
96get(key):
97 | WithVirtualProps<T, TKey>
98 | undefined;
99```
100
101Defined in: [packages/db/src/collection/index.ts:680](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L680)
102
103Get the current value for a key (virtual derived state)
104
105#### Parameters
106
107##### key
108
109`TKey`
110
111#### Returns
112
113 \| [`WithVirtualProps`](../type-aliases/WithVirtualProps.md)\<`T`, `TKey`\>
114 \| `undefined`
115
116#### Inherited from
117
118```ts
119Pick.get
120```
121
122***
123
124### has()
125
126```ts
127has(key): boolean;
128```
129
130Defined in: [packages/db/src/collection/index.ts:687](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L687)
131
132Check if a key exists in the collection (virtual derived state)
133
134#### Parameters
135
136##### key
137
138`TKey`
139
140#### Returns
141
142`boolean`
143
144#### Inherited from
145
146```ts
147Pick.has
148```