summaryrefslogtreecommitdiff
path: root/ext/js/data/database.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/data/database.js')
-rw-r--r--ext/js/data/database.js21
1 files changed, 16 insertions, 5 deletions
diff --git a/ext/js/data/database.js b/ext/js/data/database.js
index e8575be2..7f37347b 100644
--- a/ext/js/data/database.js
+++ b/ext/js/data/database.js
@@ -194,7 +194,8 @@ export class Database {
request.onsuccess = (e) => {
const cursor = /** @type {IDBRequest<?IDBCursorWithValue>} */ (e.target).result;
if (cursor) {
- const {value} = cursor;
+ /** @type {TResult} */
+ const value = cursor.value;
if (noPredicate || predicate(value, predicateArg)) {
resolve(value, data);
} else {
@@ -353,7 +354,9 @@ export class Database {
for (const {version, stores} of upgrades) {
if (oldVersion >= version) { continue; }
- for (const [objectStoreName, {primaryKey, indices}] of Object.entries(stores)) {
+ /** @type {[objectStoreName: string, value: import('database').StoreDefinition][]} */
+ const entries = Object.entries(stores);
+ for (const [objectStoreName, {primaryKey, indices}] of entries) {
const existingObjectStoreNames = transaction.objectStoreNames || db.objectStoreNames;
const objectStore = (
this._listContains(existingObjectStoreNames, objectStoreName) ?
@@ -394,8 +397,14 @@ export class Database {
*/
_getAllFast(objectStoreOrIndex, query, onSuccess, onReject, data) {
const request = objectStoreOrIndex.getAll(query);
- request.onerror = (e) => onReject(/** @type {IDBRequest<import('core').SafeAny[]>} */ (e.target).error, data);
- request.onsuccess = (e) => onSuccess(/** @type {IDBRequest<import('core').SafeAny[]>} */ (e.target).result, data);
+ request.onerror = (e) => {
+ const target = /** @type {IDBRequest<TResult[]>} */ (e.target);
+ onReject(target.error, data);
+ };
+ request.onsuccess = (e) => {
+ const target = /** @type {IDBRequest<TResult[]>} */ (e.target);
+ onSuccess(target.result, data);
+ };
}
/**
@@ -415,7 +424,9 @@ export class Database {
request.onsuccess = (e) => {
const cursor = /** @type {IDBRequest<?IDBCursorWithValue>} */ (e.target).result;
if (cursor) {
- results.push(cursor.value);
+ /** @type {TResult} */
+ const value = cursor.value;
+ results.push(value);
cursor.continue();
} else {
onSuccess(results, data);