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

IndexedDBCollectionUtils.md

125 lines1.9 KB

1---
2id: IndexedDBCollectionUtils
3title: IndexedDBCollectionUtils
4---
5​
6Defined in: packages/db/src/indexed-db.ts:206
7​
8Utility functions exposed on collection.utils
9​
10## Extends
11​
12- [`UtilsRecord`](../type-aliases/UtilsRecord.md)
13​
14## Type Parameters
15​
16### TItem
17​
18`TItem` *extends* `object` = `Record`\<`string`, `unknown`\>
19​
20### TInsertInput
21​
22`TInsertInput` *extends* `object` = `TItem`
23​
24## Indexable
25​
26```ts
27[key: string]: any
28```
29​
30## Properties
31​
32### acceptMutations()
33​
34```ts
35acceptMutations: (transaction) => Promise<void>;
36```
37​
38Defined in: packages/db/src/indexed-db.ts:224
39​
40Accepts mutations from a manual transaction and persists to IndexedDB
41​
42#### Parameters
43​
44##### transaction
45​
46###### mutations
47​
48[`PendingMutation`](PendingMutation.md)\<`Record`\<`string`, `unknown`\>, [`OperationType`](../type-aliases/OperationType.md), [`Collection`](Collection.md)\<`Record`\<`string`, `unknown`\>, `any`, `any`, `any`, `any`\>\>[]
49​
50#### Returns
51​
52`Promise`\<`void`\>
53​
54***
55​
56### clearObjectStore()
57​
58```ts
59clearObjectStore: () => Promise<void>;
60```
61​
62Defined in: packages/db/src/indexed-db.ts:214
63​
64Removes all data from the object store
65Does NOT delete the database itself
66​
67#### Returns
68​
69`Promise`\<`void`\>
70​
71***
72​
73### exportData()
74​
75```ts
76exportData: () => Promise<TItem[]>;
77```
78​
79Defined in: packages/db/src/indexed-db.ts:232
80​
81Exports all data from the object store as an array
82Useful for backup/debugging
83​
84#### Returns
85​
86`Promise`\<`TItem`[]\>
87​
88***
89​
90### getDatabaseInfo()
91​
92```ts
93getDatabaseInfo: () => Promise<DatabaseInfo>;
94```
95​
96Defined in: packages/db/src/indexed-db.ts:219
97​
98Returns database information for debugging
99​
100#### Returns
101​
102`Promise`\<[`DatabaseInfo`](DatabaseInfo.md)\>
103​
104***
105​
106### importData()
107​
108```ts
109importData: (items) => Promise<void>;
110```
111​
112Defined in: packages/db/src/indexed-db.ts:238
113​
114Validates input rows and atomically replaces the object store.
115Failure preserves the previous rows and versions.
116​
117#### Parameters
118​
119##### items
120​
121`TInsertInput`[]
122​
123#### Returns
124​
125`Promise`\<`void`\>