@workglow/indexeddb 0.3.24 → 0.3.26
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/dist/storage/node.js
CHANGED
|
@@ -1295,11 +1295,49 @@ class IndexedDbTabularStorage extends BaseTabularStorage {
|
|
|
1295
1295
|
}
|
|
1296
1296
|
async updateWhere(match, patch) {
|
|
1297
1297
|
this.assertPatchKeepsPrimaryKey(patch);
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1298
|
+
this.validateQueryParams(match);
|
|
1299
|
+
const db = await this.getDb();
|
|
1300
|
+
return new Promise((resolve, reject) => {
|
|
1301
|
+
let tx;
|
|
1302
|
+
try {
|
|
1303
|
+
tx = db.transaction(this.table, "readwrite");
|
|
1304
|
+
} catch (err) {
|
|
1305
|
+
reject(err);
|
|
1306
|
+
return;
|
|
1307
|
+
}
|
|
1308
|
+
const store = tx.objectStore(this.table);
|
|
1309
|
+
const plan = this.createIndexedRange(store, match);
|
|
1310
|
+
const source = plan?.source ?? store;
|
|
1311
|
+
const range = plan?.range;
|
|
1312
|
+
let updated;
|
|
1313
|
+
tx.oncomplete = () => {
|
|
1314
|
+
if (updated !== undefined) {
|
|
1315
|
+
safeEmit(this.events, "put", updated);
|
|
1316
|
+
this.hybridManager?.notifyLocalChange();
|
|
1317
|
+
}
|
|
1318
|
+
resolve(updated);
|
|
1319
|
+
};
|
|
1320
|
+
tx.onerror = () => reject(tx.error);
|
|
1321
|
+
tx.onabort = () => reject(tx.error ?? new Error("updateWhere transaction aborted"));
|
|
1322
|
+
const request = source.openCursor(range);
|
|
1323
|
+
request.onerror = () => reject(request.error);
|
|
1324
|
+
request.onsuccess = () => {
|
|
1325
|
+
const cursor = request.result;
|
|
1326
|
+
if (!cursor)
|
|
1327
|
+
return;
|
|
1328
|
+
const record = cursor.value;
|
|
1329
|
+
if (!this.matchesCriteria(record, match)) {
|
|
1330
|
+
cursor.continue();
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
const candidate = { ...record, ...patch };
|
|
1334
|
+
const updateRequest = cursor.update(candidate);
|
|
1335
|
+
updateRequest.onsuccess = () => {
|
|
1336
|
+
updated = candidate;
|
|
1337
|
+
};
|
|
1338
|
+
updateRequest.onerror = () => {};
|
|
1339
|
+
};
|
|
1340
|
+
});
|
|
1303
1341
|
}
|
|
1304
1342
|
getEqualityCriterionValue(criteria, column) {
|
|
1305
1343
|
const criterion = criteria[column];
|
|
@@ -1681,4 +1719,4 @@ export {
|
|
|
1681
1719
|
IDB_KV_REPOSITORY
|
|
1682
1720
|
};
|
|
1683
1721
|
|
|
1684
|
-
//# debugId=
|
|
1722
|
+
//# debugId=D29EE9DD7220F18B64756E2164756E21
|