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