web-idb-client 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +230 -0
- package/dist/client/index.d.ts +7 -0
- package/dist/client/index.js +12 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/indexed-db-client.d.ts +40 -0
- package/dist/client/indexed-db-client.js +211 -0
- package/dist/client/indexed-db-client.js.map +1 -0
- package/dist/client/mutations.d.ts +12 -0
- package/dist/client/mutations.js +3 -0
- package/dist/client/mutations.js.map +1 -0
- package/dist/client/store.d.ts +42 -0
- package/dist/client/store.js +356 -0
- package/dist/client/store.js.map +1 -0
- package/dist/client/transaction.d.ts +14 -0
- package/dist/client/transaction.js +37 -0
- package/dist/client/transaction.js.map +1 -0
- package/dist/errors/index.d.ts +15 -0
- package/dist/errors/index.js +35 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/liveQuery/index.d.ts +31 -0
- package/dist/liveQuery/index.js +216 -0
- package/dist/liveQuery/index.js.map +1 -0
- package/dist/migrate/diff.d.ts +28 -0
- package/dist/migrate/diff.js +89 -0
- package/dist/migrate/diff.js.map +1 -0
- package/dist/migrate/helpers.d.ts +29 -0
- package/dist/migrate/helpers.js +89 -0
- package/dist/migrate/helpers.js.map +1 -0
- package/dist/migrate/index.d.ts +6 -0
- package/dist/migrate/index.js +14 -0
- package/dist/migrate/index.js.map +1 -0
- package/dist/migrate/upgrade.d.ts +19 -0
- package/dist/migrate/upgrade.js +123 -0
- package/dist/migrate/upgrade.js.map +1 -0
- package/dist/query/order.d.ts +8 -0
- package/dist/query/order.js +30 -0
- package/dist/query/order.js.map +1 -0
- package/dist/query/where.d.ts +17 -0
- package/dist/query/where.js +106 -0
- package/dist/query/where.js.map +1 -0
- package/dist/relation/define-relation.d.ts +49 -0
- package/dist/relation/define-relation.js +101 -0
- package/dist/relation/define-relation.js.map +1 -0
- package/dist/relation/index.d.ts +3 -0
- package/dist/relation/index.js +14 -0
- package/dist/relation/index.js.map +1 -0
- package/dist/relation/load-related.d.ts +21 -0
- package/dist/relation/load-related.js +54 -0
- package/dist/relation/load-related.js.map +1 -0
- package/dist/schema/define-db.d.ts +5 -0
- package/dist/schema/define-db.js +41 -0
- package/dist/schema/define-db.js.map +1 -0
- package/dist/schema/define-store.d.ts +17 -0
- package/dist/schema/define-store.js +95 -0
- package/dist/schema/define-store.js.map +1 -0
- package/dist/schema/fields.d.ts +75 -0
- package/dist/schema/fields.js +90 -0
- package/dist/schema/fields.js.map +1 -0
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.js +22 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/infer.d.ts +131 -0
- package/dist/schema/infer.js +3 -0
- package/dist/schema/infer.js.map +1 -0
- package/dist/schema/infer.test-types.d.ts +11 -0
- package/dist/schema/infer.test-types.js +80 -0
- package/dist/schema/infer.test-types.js.map +1 -0
- package/dist/schema/types.d.ts +55 -0
- package/dist/schema/types.js +3 -0
- package/dist/schema/types.js.map +1 -0
- package/dist/utils/assert-keys.d.ts +3 -0
- package/dist/utils/assert-keys.js +15 -0
- package/dist/utils/assert-keys.js.map +1 -0
- package/dist/utils/boolean-codec.d.ts +23 -0
- package/dist/utils/boolean-codec.js +149 -0
- package/dist/utils/boolean-codec.js.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +16 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/key-range.d.ts +14 -0
- package/dist/utils/key-range.js +157 -0
- package/dist/utils/key-range.js.map +1 -0
- package/dist/utils/promisify.d.ts +2 -0
- package/dist/utils/promisify.js +29 -0
- package/dist/utils/promisify.js.map +1 -0
- package/dist/utils/type-utils.d.ts +2 -0
- package/dist/utils/type-utils.js +3 -0
- package/dist/utils/type-utils.js.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Store = void 0;
|
|
13
|
+
const where_1 = require("../query/where");
|
|
14
|
+
const order_1 = require("../query/order");
|
|
15
|
+
const promisify_1 = require("../utils/promisify");
|
|
16
|
+
const key_range_1 = require("../utils/key-range");
|
|
17
|
+
const boolean_codec_1 = require("../utils/boolean-codec");
|
|
18
|
+
const assert_keys_1 = require("../utils/assert-keys");
|
|
19
|
+
const errors_1 = require("../errors");
|
|
20
|
+
function readPath(row, keyPath) {
|
|
21
|
+
if (Array.isArray(keyPath)) {
|
|
22
|
+
return keyPath.map((part) => row[part]);
|
|
23
|
+
}
|
|
24
|
+
return row[keyPath];
|
|
25
|
+
}
|
|
26
|
+
function compareKeys(a, b) {
|
|
27
|
+
if (a === b) {
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
if (a === undefined || a === null) {
|
|
31
|
+
return -1;
|
|
32
|
+
}
|
|
33
|
+
if (b === undefined || b === null) {
|
|
34
|
+
return 1;
|
|
35
|
+
}
|
|
36
|
+
if (a instanceof Date && b instanceof Date) {
|
|
37
|
+
return a.getTime() - b.getTime();
|
|
38
|
+
}
|
|
39
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
40
|
+
const len = Math.min(a.length, b.length);
|
|
41
|
+
for (let i = 0; i < len; i++) {
|
|
42
|
+
const cmp = compareKeys(a[i], b[i]);
|
|
43
|
+
if (cmp !== 0) {
|
|
44
|
+
return cmp;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return a.length - b.length;
|
|
48
|
+
}
|
|
49
|
+
if (typeof a === 'number' && typeof b === 'number') {
|
|
50
|
+
return a - b;
|
|
51
|
+
}
|
|
52
|
+
if (typeof a === 'boolean' && typeof b === 'boolean') {
|
|
53
|
+
return Number(a) - Number(b);
|
|
54
|
+
}
|
|
55
|
+
return String(a).localeCompare(String(b));
|
|
56
|
+
}
|
|
57
|
+
function sortRowsInMemory(store, rows, orderBy) {
|
|
58
|
+
const entries = Object.entries(orderBy);
|
|
59
|
+
if (entries.length === 0) {
|
|
60
|
+
return rows;
|
|
61
|
+
}
|
|
62
|
+
const [field, direction] = entries[0];
|
|
63
|
+
const mult = direction === 'desc' ? -1 : 1;
|
|
64
|
+
let keyPath = field;
|
|
65
|
+
if (field === store.primaryKey.keyPath) {
|
|
66
|
+
keyPath = store.primaryKey.keyPath;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const index = store.indexes.find((i) => i.name === field || i.keyPath === field);
|
|
70
|
+
if (index) {
|
|
71
|
+
keyPath = index.keyPath;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return [...rows].sort((left, right) => compareKeys(readPath(left, keyPath), readPath(right, keyPath)) * mult);
|
|
75
|
+
}
|
|
76
|
+
class Store {
|
|
77
|
+
constructor(def, ctx) {
|
|
78
|
+
this.def = def;
|
|
79
|
+
this.ctx = ctx;
|
|
80
|
+
}
|
|
81
|
+
get name() {
|
|
82
|
+
return this.def.name;
|
|
83
|
+
}
|
|
84
|
+
encodeWhere(where) {
|
|
85
|
+
return (0, boolean_codec_1.encodeWhereForStorage)(this.def, where);
|
|
86
|
+
}
|
|
87
|
+
decodeRow(row) {
|
|
88
|
+
return (0, boolean_codec_1.decodeRowFromStorage)(this.def, row);
|
|
89
|
+
}
|
|
90
|
+
decodeRows(rows) {
|
|
91
|
+
return rows.map((row) => this.decodeRow(row));
|
|
92
|
+
}
|
|
93
|
+
notify(op) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
(_b = (_a = this.ctx).onMutate) === null || _b === void 0 ? void 0 : _b.call(_a, { store: this.def.name, op });
|
|
96
|
+
}
|
|
97
|
+
insert(data) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
if (this.ctx.strictInsert) {
|
|
100
|
+
(0, assert_keys_1.assertKnownInsertKeys)(this.def, data);
|
|
101
|
+
}
|
|
102
|
+
const store = this.ctx.getObjectStore('readwrite');
|
|
103
|
+
const encoded = (0, boolean_codec_1.encodeRowForStorage)(this.def, data);
|
|
104
|
+
const key = yield (0, promisify_1.promisifyRequest)(store.add(encoded));
|
|
105
|
+
this.notify('insert');
|
|
106
|
+
return key;
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
insertMany(data) {
|
|
110
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
111
|
+
const store = this.ctx.getObjectStore('readwrite');
|
|
112
|
+
const keys = [];
|
|
113
|
+
for (const row of data) {
|
|
114
|
+
if (this.ctx.strictInsert) {
|
|
115
|
+
(0, assert_keys_1.assertKnownInsertKeys)(this.def, row);
|
|
116
|
+
}
|
|
117
|
+
const encoded = (0, boolean_codec_1.encodeRowForStorage)(this.def, row);
|
|
118
|
+
keys.push(yield (0, promisify_1.promisifyRequest)(store.add(encoded)));
|
|
119
|
+
}
|
|
120
|
+
if (keys.length > 0) {
|
|
121
|
+
this.notify('insertMany');
|
|
122
|
+
}
|
|
123
|
+
return keys;
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
find(params) {
|
|
127
|
+
var _a;
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
const rows = yield this.findMany({
|
|
130
|
+
where: params.where,
|
|
131
|
+
orderBy: params.orderBy,
|
|
132
|
+
sortInMemory: params.sortInMemory,
|
|
133
|
+
take: 1,
|
|
134
|
+
});
|
|
135
|
+
return (_a = rows[0]) !== null && _a !== void 0 ? _a : null;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
findUnique(params) {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
140
|
+
if (!(0, where_1.isUniqueTarget)(this.def, params.where)) {
|
|
141
|
+
throw new errors_1.IndexedDbError('QUERY_INVALID', 'findUnique requires a primary key or unique index in where', { store: this.def.name });
|
|
142
|
+
}
|
|
143
|
+
return this.find({
|
|
144
|
+
where: params.where,
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
findMany(params = {}) {
|
|
149
|
+
var _a;
|
|
150
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
151
|
+
const objectStore = this.ctx.getObjectStore('readonly');
|
|
152
|
+
const resolved = (0, where_1.resolveWhere)(this.def, this.encodeWhere(params.where));
|
|
153
|
+
const order = (0, order_1.resolveOrderBy)(this.def, params.orderBy);
|
|
154
|
+
const skip = (_a = params.skip) !== null && _a !== void 0 ? _a : 0;
|
|
155
|
+
const take = params.take;
|
|
156
|
+
const conflicts = Boolean(order) &&
|
|
157
|
+
(0, where_1.orderConflictsWithWhere)(this.def, resolved, order === null || order === void 0 ? void 0 : order.indexName);
|
|
158
|
+
if (conflicts) {
|
|
159
|
+
if (!params.sortInMemory) {
|
|
160
|
+
throw new errors_1.IndexedDbError('QUERY_INVALID', 'orderBy index must match the where index in v2. Pass sortInMemory: true to sort the where-result in memory (can be expensive).', { store: this.def.name });
|
|
161
|
+
}
|
|
162
|
+
const unordered = yield this.findMany({
|
|
163
|
+
where: params.where,
|
|
164
|
+
skip: 0,
|
|
165
|
+
take: undefined,
|
|
166
|
+
sortInMemory: false,
|
|
167
|
+
});
|
|
168
|
+
const sorted = sortRowsInMemory(this.def, unordered, params.orderBy);
|
|
169
|
+
return take !== undefined
|
|
170
|
+
? sorted.slice(skip, skip + take)
|
|
171
|
+
: sorted.slice(skip);
|
|
172
|
+
}
|
|
173
|
+
const needsCursor = Boolean(order) || skip > 0 || (order === null || order === void 0 ? void 0 : order.direction) === 'prev';
|
|
174
|
+
if (!needsCursor) {
|
|
175
|
+
const source = resolved.source === 'index' && resolved.indexName
|
|
176
|
+
? objectStore.index(resolved.indexName)
|
|
177
|
+
: objectStore;
|
|
178
|
+
const range = (0, key_range_1.toOptionalKeyRange)(resolved.keyRange);
|
|
179
|
+
if (take !== undefined) {
|
|
180
|
+
const rows = (yield (0, promisify_1.promisifyRequest)(source.getAll(range, take)));
|
|
181
|
+
return this.decodeRows(rows);
|
|
182
|
+
}
|
|
183
|
+
const rows = (yield (0, promisify_1.promisifyRequest)(source.getAll(range)));
|
|
184
|
+
return this.decodeRows(rows);
|
|
185
|
+
}
|
|
186
|
+
return this.collectWithCursor(objectStore, resolved, order, skip, take);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
count(params = {}) {
|
|
190
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
const objectStore = this.ctx.getObjectStore('readonly');
|
|
192
|
+
const resolved = (0, where_1.resolveWhere)(this.def, this.encodeWhere(params.where));
|
|
193
|
+
const source = resolved.source === 'index' && resolved.indexName
|
|
194
|
+
? objectStore.index(resolved.indexName)
|
|
195
|
+
: objectStore;
|
|
196
|
+
return (0, promisify_1.promisifyRequest)(source.count((0, key_range_1.toOptionalKeyRange)(resolved.keyRange)));
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
update(params) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
201
|
+
const rows = yield this.findMany({ where: params.where });
|
|
202
|
+
if (rows.length === 0) {
|
|
203
|
+
return 0;
|
|
204
|
+
}
|
|
205
|
+
const objectStore = this.ctx.getObjectStore('readwrite');
|
|
206
|
+
let modified = 0;
|
|
207
|
+
for (const row of rows) {
|
|
208
|
+
const next = (0, boolean_codec_1.encodeRowForStorage)(this.def, Object.assign(Object.assign({}, row), params.data));
|
|
209
|
+
yield (0, promisify_1.promisifyRequest)(objectStore.put(next));
|
|
210
|
+
modified++;
|
|
211
|
+
}
|
|
212
|
+
if (modified > 0) {
|
|
213
|
+
this.notify('update');
|
|
214
|
+
}
|
|
215
|
+
return modified;
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/** Alias of `update` — updates all rows matching `where`. */
|
|
219
|
+
updateMany(params) {
|
|
220
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
+
return this.update(params);
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
delete(params) {
|
|
225
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
226
|
+
const objectStore = this.ctx.getObjectStore('readwrite');
|
|
227
|
+
const resolved = (0, where_1.resolveWhere)(this.def, this.encodeWhere(params.where));
|
|
228
|
+
if (resolved.source === 'store' &&
|
|
229
|
+
resolved.keyRange !== undefined &&
|
|
230
|
+
!(resolved.keyRange instanceof IDBKeyRange)) {
|
|
231
|
+
yield (0, promisify_1.promisifyRequest)(objectStore.delete(resolved.keyRange));
|
|
232
|
+
this.notify('delete');
|
|
233
|
+
return 1;
|
|
234
|
+
}
|
|
235
|
+
const source = resolved.source === 'index' && resolved.indexName
|
|
236
|
+
? objectStore.index(resolved.indexName)
|
|
237
|
+
: objectStore;
|
|
238
|
+
const range = (0, key_range_1.toOptionalKeyRange)(resolved.keyRange);
|
|
239
|
+
let deleted = 0;
|
|
240
|
+
const request = source.openCursor(range);
|
|
241
|
+
yield new Promise((resolve, reject) => {
|
|
242
|
+
request.onsuccess = () => {
|
|
243
|
+
const cursor = request.result;
|
|
244
|
+
if (!cursor) {
|
|
245
|
+
resolve();
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
cursor.delete();
|
|
249
|
+
deleted++;
|
|
250
|
+
cursor.continue();
|
|
251
|
+
};
|
|
252
|
+
request.onerror = () => {
|
|
253
|
+
var _a, _b;
|
|
254
|
+
return reject(new errors_1.IndexedDbError('TRANSACTION_FAILED', (_b = (_a = request.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Delete cursor failed'));
|
|
255
|
+
};
|
|
256
|
+
});
|
|
257
|
+
if (deleted > 0) {
|
|
258
|
+
this.notify('delete');
|
|
259
|
+
}
|
|
260
|
+
return deleted;
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
/** Alias of `delete` — deletes all rows matching `where`. */
|
|
264
|
+
deleteMany(params) {
|
|
265
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
266
|
+
return this.delete(params);
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
clear() {
|
|
270
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
271
|
+
const objectStore = this.ctx.getObjectStore('readwrite');
|
|
272
|
+
yield (0, promisify_1.promisifyRequest)(objectStore.clear());
|
|
273
|
+
this.notify('clear');
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Transform each record (typically inside an upgrade transaction).
|
|
278
|
+
* Return `null` to delete the record.
|
|
279
|
+
* Callback receives / returns app-level types (boolean, not 0|1).
|
|
280
|
+
*/
|
|
281
|
+
migrate(map) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
const objectStore = this.ctx.getObjectStore('readwrite');
|
|
284
|
+
const request = objectStore.openCursor();
|
|
285
|
+
yield new Promise((resolve, reject) => {
|
|
286
|
+
request.onsuccess = () => {
|
|
287
|
+
const cursor = request.result;
|
|
288
|
+
if (!cursor) {
|
|
289
|
+
resolve();
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
const decoded = this.decodeRow(cursor.value);
|
|
293
|
+
void Promise.resolve(map(decoded))
|
|
294
|
+
.then((next) => {
|
|
295
|
+
if (next === null) {
|
|
296
|
+
cursor.delete();
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
cursor.update((0, boolean_codec_1.encodeRowForStorage)(this.def, next));
|
|
300
|
+
}
|
|
301
|
+
cursor.continue();
|
|
302
|
+
})
|
|
303
|
+
.catch(reject);
|
|
304
|
+
};
|
|
305
|
+
request.onerror = () => {
|
|
306
|
+
var _a, _b;
|
|
307
|
+
return reject(new errors_1.IndexedDbError('TRANSACTION_FAILED', (_b = (_a = request.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Migrate cursor failed'));
|
|
308
|
+
};
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
collectWithCursor(objectStore, resolved, order, skip, take) {
|
|
313
|
+
var _a;
|
|
314
|
+
const direction = (_a = order === null || order === void 0 ? void 0 : order.direction) !== null && _a !== void 0 ? _a : 'next';
|
|
315
|
+
let source = objectStore;
|
|
316
|
+
if (order === null || order === void 0 ? void 0 : order.indexName) {
|
|
317
|
+
source = objectStore.index(order.indexName);
|
|
318
|
+
}
|
|
319
|
+
else if (resolved.source === 'index' && resolved.indexName) {
|
|
320
|
+
source = objectStore.index(resolved.indexName);
|
|
321
|
+
}
|
|
322
|
+
if ((0, where_1.orderConflictsWithWhere)(this.def, resolved, order === null || order === void 0 ? void 0 : order.indexName)) {
|
|
323
|
+
throw new errors_1.IndexedDbError('QUERY_INVALID', 'orderBy index must match the where index in v2. Pass sortInMemory: true to sort the where-result in memory (can be expensive).', { store: this.def.name });
|
|
324
|
+
}
|
|
325
|
+
const range = (0, key_range_1.toOptionalKeyRange)(resolved.keyRange);
|
|
326
|
+
const values = [];
|
|
327
|
+
let skipped = 0;
|
|
328
|
+
return new Promise((resolve, reject) => {
|
|
329
|
+
const request = source.openCursor(range, direction);
|
|
330
|
+
request.onsuccess = () => {
|
|
331
|
+
const cursor = request.result;
|
|
332
|
+
if (!cursor) {
|
|
333
|
+
resolve(values);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (skipped < skip) {
|
|
337
|
+
skipped++;
|
|
338
|
+
cursor.continue();
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
if (take !== undefined && values.length >= take) {
|
|
342
|
+
resolve(values);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
values.push(this.decodeRow(cursor.value));
|
|
346
|
+
cursor.continue();
|
|
347
|
+
};
|
|
348
|
+
request.onerror = () => {
|
|
349
|
+
var _a, _b;
|
|
350
|
+
return reject(new errors_1.IndexedDbError('TRANSACTION_FAILED', (_b = (_a = request.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'Cursor failed'));
|
|
351
|
+
};
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
exports.Store = Store;
|
|
356
|
+
//# sourceMappingURL=store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/client/store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAaA,0CAAuF;AACvF,0CAAgD;AAChD,kDAAsD;AACtD,kDAAwD;AACxD,0DAIgC;AAChC,sDAA6D;AAC7D,sCAA2C;AAW3C,SAAS,QAAQ,CAAC,GAA4B,EAAE,OAA0B;IACxE,IAAI,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;KACzC;IACD,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;AACtB,CAAC;AAED,SAAS,WAAW,CAAC,CAAU,EAAE,CAAU;IACzC,IAAI,CAAC,KAAK,CAAC,EAAE;QACX,OAAO,CAAC,CAAC;KACV;IACD,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,EAAE;QACjC,OAAO,CAAC,CAAC,CAAC;KACX;IACD,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,IAAI,EAAE;QACjC,OAAO,CAAC,CAAC;KACV;IACD,IAAI,CA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,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,MAAM,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;YACpD,OAAO,CAAC,SAAS,GAAG,GAAG,EAAE;gBACvB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;gBAC9B,IAAI,CAAC,MAAM,EAAE;oBACX,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,OAAO;iBACR;gBACD,IAAI,OAAO,GAAG,IAAI,EAAE;oBAClB,OAAO,EAAE,CAAC;oBACV,MAAM,CAAC,QAAQ,EAAE,CAAC;oBAClB,OAAO;iBACR;gBACD,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE;oBAC/C,OAAO,CAAC,MAAM,CAAC,CAAC;oBAChB,OAAO;iBACR;gBACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAgC,CAAC,CAAC,CAAC;gBACrE,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,CAAC,CAAC;YACF,OAAO,CAAC,OAAO,GAAG,GAAG,EAAE;;gBACrB,OAAA,MAAM,CACJ,IAAI,uBAAc,CAChB,oBAAoB,EACpB,MAAA,MAAA,OAAO,CAAC,KAAK,0CAAE,OAAO,mCAAI,eAAe,CAC1C,CACF,CAAA;aAAA,CAAC;QACN,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAzWD,sBAyWC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DbStoresInterface } from '../schema/types';
|
|
2
|
+
import { Store } from './store';
|
|
3
|
+
import type { StoreMutationEvent } from './mutations';
|
|
4
|
+
export type TransactionMode = 'r' | 'rw';
|
|
5
|
+
export type TxStores<TStores extends DbStoresInterface> = {
|
|
6
|
+
[K in keyof TStores]: Store<TStores[K]>;
|
|
7
|
+
};
|
|
8
|
+
export declare class Transaction<TStores extends DbStoresInterface> {
|
|
9
|
+
readonly idbTransaction: IDBTransaction;
|
|
10
|
+
readonly stores: TxStores<TStores>;
|
|
11
|
+
constructor(idbTransaction: IDBTransaction, storeDefs: TStores, storeNames: (keyof TStores & string)[], strictInsert?: boolean, onMutate?: (event: StoreMutationEvent) => void);
|
|
12
|
+
done(): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
export declare function toIndexedDbTransactionMode(mode: TransactionMode): IDBTransactionMode;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toIndexedDbTransactionMode = exports.Transaction = void 0;
|
|
4
|
+
const store_1 = require("./store");
|
|
5
|
+
const promisify_1 = require("../utils/promisify");
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
class Transaction {
|
|
8
|
+
constructor(idbTransaction, storeDefs, storeNames, strictInsert = false, onMutate) {
|
|
9
|
+
this.idbTransaction = idbTransaction;
|
|
10
|
+
const stores = {};
|
|
11
|
+
for (const name of storeNames) {
|
|
12
|
+
const def = storeDefs[name];
|
|
13
|
+
stores[name] = new store_1.Store(def, {
|
|
14
|
+
getObjectStore: () => {
|
|
15
|
+
try {
|
|
16
|
+
return idbTransaction.objectStore(def.name);
|
|
17
|
+
}
|
|
18
|
+
catch (_a) {
|
|
19
|
+
throw new errors_1.IndexedDbError('TRANSACTION_FAILED', `Store "${String(name)}" is not in the current transaction`, { store: def.name });
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
strictInsert,
|
|
23
|
+
onMutate,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
this.stores = stores;
|
|
27
|
+
}
|
|
28
|
+
done() {
|
|
29
|
+
return (0, promisify_1.transactionDone)(this.idbTransaction);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.Transaction = Transaction;
|
|
33
|
+
function toIndexedDbTransactionMode(mode) {
|
|
34
|
+
return mode === 'r' ? 'readonly' : 'readwrite';
|
|
35
|
+
}
|
|
36
|
+
exports.toIndexedDbTransactionMode = toIndexedDbTransactionMode;
|
|
37
|
+
//# sourceMappingURL=transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../src/client/transaction.ts"],"names":[],"mappings":";;;AACA,mCAAgC;AAEhC,kDAAqD;AACrD,sCAA2C;AAQ3C,MAAa,WAAW;IAItB,YACE,cAA8B,EAC9B,SAAkB,EAClB,UAAsC,EACtC,YAAY,GAAG,KAAK,EACpB,QAA8C;QAE9C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,MAAM,MAAM,GAAG,EAAuB,CAAC;QACvC,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE;YAC7B,MAAM,GAAG,GAAG,SAAS,CAAC,IAAI,CAAmB,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC,GAAG,IAAI,aAAK,CAAC,GAAG,EAAE;gBAC5B,cAAc,EAAE,GAAG,EAAE;oBACnB,IAAI;wBACF,OAAO,cAAc,CAAC,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;qBAC7C;oBAAC,WAAM;wBACN,MAAM,IAAI,uBAAc,CACtB,oBAAoB,EACpB,UAAU,MAAM,CAAC,IAAI,CAAC,qCAAqC,EAC3D,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,CACpB,CAAC;qBACH;gBACH,CAAC;gBACD,YAAY;gBACZ,QAAQ;aACT,CAAmC,CAAC;SACtC;QACD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,IAAI;QACF,OAAO,IAAA,2BAAe,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IAC9C,CAAC;CACF;AArCD,kCAqCC;AAED,SAAgB,0BAA0B,CACxC,IAAqB;IAErB,OAAO,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;AACjD,CAAC;AAJD,gEAIC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type IndexedDbErrorCode = 'NOT_OPEN' | 'SCHEMA_INVALID' | 'SCHEMA_MISMATCH' | 'QUERY_INVALID' | 'TRANSACTION_FAILED' | 'OPEN_FAILED' | 'BLOCKED';
|
|
2
|
+
export interface IndexedDbErrorContext {
|
|
3
|
+
store?: string;
|
|
4
|
+
index?: string;
|
|
5
|
+
field?: string;
|
|
6
|
+
cause?: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare class IndexedDbError extends Error {
|
|
9
|
+
readonly code: IndexedDbErrorCode;
|
|
10
|
+
readonly store?: string;
|
|
11
|
+
readonly index?: string;
|
|
12
|
+
readonly field?: string;
|
|
13
|
+
readonly cause?: unknown;
|
|
14
|
+
constructor(code: IndexedDbErrorCode, message: string, context?: IndexedDbErrorContext);
|
|
15
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IndexedDbError = void 0;
|
|
4
|
+
function formatMessage(message, context) {
|
|
5
|
+
if (!context) {
|
|
6
|
+
return message;
|
|
7
|
+
}
|
|
8
|
+
const bits = [];
|
|
9
|
+
if (context.store) {
|
|
10
|
+
bits.push(`store=${context.store}`);
|
|
11
|
+
}
|
|
12
|
+
if (context.index) {
|
|
13
|
+
bits.push(`index=${context.index}`);
|
|
14
|
+
}
|
|
15
|
+
if (context.field) {
|
|
16
|
+
bits.push(`field=${context.field}`);
|
|
17
|
+
}
|
|
18
|
+
if (bits.length === 0) {
|
|
19
|
+
return message;
|
|
20
|
+
}
|
|
21
|
+
return `${message} (${bits.join(', ')})`;
|
|
22
|
+
}
|
|
23
|
+
class IndexedDbError extends Error {
|
|
24
|
+
constructor(code, message, context) {
|
|
25
|
+
super(formatMessage(message, context));
|
|
26
|
+
this.name = 'IndexedDbError';
|
|
27
|
+
this.code = code;
|
|
28
|
+
this.store = context === null || context === void 0 ? void 0 : context.store;
|
|
29
|
+
this.index = context === null || context === void 0 ? void 0 : context.index;
|
|
30
|
+
this.field = context === null || context === void 0 ? void 0 : context.field;
|
|
31
|
+
this.cause = context === null || context === void 0 ? void 0 : context.cause;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.IndexedDbError = IndexedDbError;
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":";;;AAgBA,SAAS,aAAa,CACpB,OAAe,EACf,OAA+B;IAE/B,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,OAAO,CAAC;KAChB;IACD,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,OAAO,CAAC,KAAK,EAAE;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;KACrC;IACD,IAAI,OAAO,CAAC,KAAK,EAAE;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;KACrC;IACD,IAAI,OAAO,CAAC,KAAK,EAAE;QACjB,IAAI,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;KACrC;IACD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;QACrB,OAAO,OAAO,CAAC;KAChB;IACD,OAAO,GAAG,OAAO,KAAK,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAC3C,CAAC;AAED,MAAa,cAAe,SAAQ,KAAK;IAOvC,YACE,IAAwB,EACxB,OAAe,EACf,OAA+B;QAE/B,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,KAAK,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,CAAC;IAC9B,CAAC;CACF;AApBD,wCAoBC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { IndexedDbError } from './errors';
|
|
2
|
+
export type { IndexedDbErrorCode, IndexedDbErrorContext } from './errors';
|
|
3
|
+
export { field, Field, defineStore, compoundIndex, toDeclaredDbSchema, toDeclaredStoreSchema, } from './schema';
|
|
4
|
+
export type { FieldInterface, FieldKind, FieldRefInterface, StoreInterface, DbConfigInterface, DbStoresInterface, IndexInterface, PrimaryKeyInterface, InferSelect, InferInsert, InferUpdate, WhereInputInterface, UniqueWhereInputInterface, OrderByInputInterface, FindManyParamsInterface, FindParamsInterface, UpdateParamsInterface, DeleteParamsInterface, CountParamsInterface, UpgradeFn, UpgradeContextInterface, } from './schema';
|
|
5
|
+
export { IndexedDbClient, createClient, Store, Transaction, } from './client';
|
|
6
|
+
export type { IndexedDbClientWithStores, TransactionMode, TxStores, MutationBatch, MutationListener, MutationOp, StoreMutationEvent, } from './client';
|
|
7
|
+
export { addIndex, dropIndex, copyStoreAndDrop, applySchemaUpgrade, diffSchema, } from './migrate';
|
|
8
|
+
export type { CopyStoreAndDropOptions } from './migrate';
|
|
9
|
+
export { relation, end, loadMany, loadOne, findByForeignKey, assertRelationValid, assertRefsValid, assertAllRefsValid, } from './relation';
|
|
10
|
+
export type { RelationInterface, RelationType, RelationEndpoint, } from './relation';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertAllRefsValid = exports.assertRefsValid = exports.assertRelationValid = exports.findByForeignKey = exports.loadOne = exports.loadMany = exports.end = exports.relation = exports.diffSchema = exports.applySchemaUpgrade = exports.copyStoreAndDrop = exports.dropIndex = exports.addIndex = exports.Transaction = exports.Store = exports.createClient = exports.IndexedDbClient = exports.toDeclaredStoreSchema = exports.toDeclaredDbSchema = exports.compoundIndex = exports.defineStore = exports.Field = exports.field = exports.IndexedDbError = void 0;
|
|
4
|
+
var errors_1 = require("./errors");
|
|
5
|
+
Object.defineProperty(exports, "IndexedDbError", { enumerable: true, get: function () { return errors_1.IndexedDbError; } });
|
|
6
|
+
var schema_1 = require("./schema");
|
|
7
|
+
Object.defineProperty(exports, "field", { enumerable: true, get: function () { return schema_1.field; } });
|
|
8
|
+
Object.defineProperty(exports, "Field", { enumerable: true, get: function () { return schema_1.Field; } });
|
|
9
|
+
Object.defineProperty(exports, "defineStore", { enumerable: true, get: function () { return schema_1.defineStore; } });
|
|
10
|
+
Object.defineProperty(exports, "compoundIndex", { enumerable: true, get: function () { return schema_1.compoundIndex; } });
|
|
11
|
+
Object.defineProperty(exports, "toDeclaredDbSchema", { enumerable: true, get: function () { return schema_1.toDeclaredDbSchema; } });
|
|
12
|
+
Object.defineProperty(exports, "toDeclaredStoreSchema", { enumerable: true, get: function () { return schema_1.toDeclaredStoreSchema; } });
|
|
13
|
+
var client_1 = require("./client");
|
|
14
|
+
Object.defineProperty(exports, "IndexedDbClient", { enumerable: true, get: function () { return client_1.IndexedDbClient; } });
|
|
15
|
+
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
|
|
16
|
+
Object.defineProperty(exports, "Store", { enumerable: true, get: function () { return client_1.Store; } });
|
|
17
|
+
Object.defineProperty(exports, "Transaction", { enumerable: true, get: function () { return client_1.Transaction; } });
|
|
18
|
+
var migrate_1 = require("./migrate");
|
|
19
|
+
Object.defineProperty(exports, "addIndex", { enumerable: true, get: function () { return migrate_1.addIndex; } });
|
|
20
|
+
Object.defineProperty(exports, "dropIndex", { enumerable: true, get: function () { return migrate_1.dropIndex; } });
|
|
21
|
+
Object.defineProperty(exports, "copyStoreAndDrop", { enumerable: true, get: function () { return migrate_1.copyStoreAndDrop; } });
|
|
22
|
+
Object.defineProperty(exports, "applySchemaUpgrade", { enumerable: true, get: function () { return migrate_1.applySchemaUpgrade; } });
|
|
23
|
+
Object.defineProperty(exports, "diffSchema", { enumerable: true, get: function () { return migrate_1.diffSchema; } });
|
|
24
|
+
var relation_1 = require("./relation");
|
|
25
|
+
Object.defineProperty(exports, "relation", { enumerable: true, get: function () { return relation_1.relation; } });
|
|
26
|
+
Object.defineProperty(exports, "end", { enumerable: true, get: function () { return relation_1.end; } });
|
|
27
|
+
Object.defineProperty(exports, "loadMany", { enumerable: true, get: function () { return relation_1.loadMany; } });
|
|
28
|
+
Object.defineProperty(exports, "loadOne", { enumerable: true, get: function () { return relation_1.loadOne; } });
|
|
29
|
+
Object.defineProperty(exports, "findByForeignKey", { enumerable: true, get: function () { return relation_1.findByForeignKey; } });
|
|
30
|
+
Object.defineProperty(exports, "assertRelationValid", { enumerable: true, get: function () { return relation_1.assertRelationValid; } });
|
|
31
|
+
Object.defineProperty(exports, "assertRefsValid", { enumerable: true, get: function () { return relation_1.assertRefsValid; } });
|
|
32
|
+
Object.defineProperty(exports, "assertAllRefsValid", { enumerable: true, get: function () { return relation_1.assertAllRefsValid; } });
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA0C;AAAjC,wGAAA,cAAc,OAAA;AAGvB,mCAOkB;AANhB,+FAAA,KAAK,OAAA;AACL,+FAAA,KAAK,OAAA;AACL,qGAAA,WAAW,OAAA;AACX,uGAAA,aAAa,OAAA;AACb,4GAAA,kBAAkB,OAAA;AAClB,+GAAA,qBAAqB,OAAA;AA0BvB,mCAKkB;AAJhB,yGAAA,eAAe,OAAA;AACf,sGAAA,YAAY,OAAA;AACZ,+FAAA,KAAK,OAAA;AACL,qGAAA,WAAW,OAAA;AAYb,qCAMmB;AALjB,mGAAA,QAAQ,OAAA;AACR,oGAAA,SAAS,OAAA;AACT,2GAAA,gBAAgB,OAAA;AAChB,6GAAA,kBAAkB,OAAA;AAClB,qGAAA,UAAU,OAAA;AAIZ,uCASoB;AARlB,oGAAA,QAAQ,OAAA;AACR,+FAAA,GAAG,OAAA;AACH,oGAAA,QAAQ,OAAA;AACR,mGAAA,OAAO,OAAA;AACP,4GAAA,gBAAgB,OAAA;AAChB,+GAAA,mBAAmB,OAAA;AACnB,2GAAA,eAAe,OAAA;AACf,8GAAA,kBAAkB,OAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { IndexedDbClient } from '../client/indexed-db-client';
|
|
2
|
+
export type LiveQuerySubscriber<T> = {
|
|
3
|
+
next?: (value: T) => void;
|
|
4
|
+
error?: (error: unknown) => void;
|
|
5
|
+
complete?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export type LiveQuerySubscription = {
|
|
8
|
+
unsubscribe: () => void;
|
|
9
|
+
/** Re-run the querier without a DB mutation (e.g. UI filter change). */
|
|
10
|
+
refresh: () => void;
|
|
11
|
+
};
|
|
12
|
+
export type LiveQueryObservable<T> = {
|
|
13
|
+
subscribe: (subscriber: LiveQuerySubscriber<T>) => LiveQuerySubscription;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Opt-in reactive query (browser tabs only — not sync / mobile).
|
|
17
|
+
*
|
|
18
|
+
* Re-runs `querier` after local mutations and when other tabs signal via
|
|
19
|
+
* BroadcastChannel (with `storage` event fallback).
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { liveQuery } from 'web-idb-client/liveQuery';
|
|
23
|
+
*
|
|
24
|
+
* const sub = liveQuery(db, () => db.todos.findMany()).subscribe({
|
|
25
|
+
* next: (rows) => render(rows),
|
|
26
|
+
* error: console.error,
|
|
27
|
+
* });
|
|
28
|
+
* // later: sub.unsubscribe();
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function liveQuery<T>(client: IndexedDbClient, querier: () => T | Promise<T>): LiveQueryObservable<T>;
|