Skip to content
Source
Sign inSign up
TanStack/db
Open History to see the last commit

CollectionLike.md

147 lines2.5 KB

1---
2id: CollectionLike
3title: CollectionLike
4---
5​
6# Interface: CollectionLike\<T, TKey\>
7​
8Defined in: [packages/db/src/types.ts:13](https://github.com/TanStack/db/blob/main/packages/db/src/types.ts#L13)
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:580](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L580)
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:273](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L273)
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:565](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L565)
64​
65#### Inherited from
66​
67```ts
68Pick.indexes
69```
70​
71## Methods
72​
73### entries()
74​
75```ts
76entries(): IterableIterator<[TKey, T]>;
77```
78​
79Defined in: [packages/db/src/collection/index.ts:489](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L489)
80​
81Get all entries (virtual derived state)
82​
83#### Returns
84​
85`IterableIterator`\<\[`TKey`, `T`\]\>
86​
87#### Inherited from
88​
89```ts
90Pick.entries
91```
92​
93***
94​
95### get()
96​
97```ts
98get(key): T | undefined;
99```
100​
101Defined in: [packages/db/src/collection/index.ts:454](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L454)
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`T` \| `undefined`
114​
115#### Inherited from
116​
117```ts
118Pick.get
119```
120​
121***
122​
123### has()
124​
125```ts
126has(key): boolean;
127```
128​
129Defined in: [packages/db/src/collection/index.ts:461](https://github.com/TanStack/db/blob/main/packages/db/src/collection/index.ts#L461)
130​
131Check if a key exists in the collection (virtual derived state)
132​
133#### Parameters
134​
135##### key
136​
137`TKey`
138​
139#### Returns
140​
141`boolean`
142​
143#### Inherited from
144​
145```ts
146Pick.has
147```