Skip to content

Commit

Permalink
fixed LocalDatabase.delete not deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
LiamPerson committed Nov 2, 2022
1 parent 027211e commit 88697fa
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
17 changes: 16 additions & 1 deletion LocalDatabase.all.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,22 @@
// Get an array of keys from the results.
const keyArray = results.map(entry => entry[keyColumn]);
// Initiate delete

const deletePromises = [];
for(const key of keyArray) {
deletePromises.push(new Promise((delSuccess, delReject) => {
const txn = LocalDatabase.instance.transaction([tableSchema.name], "readwrite");
txn.objectStore(tableSchema.name).delete(key);

txn.oncomplete = event => {
delSuccess(event);
}
txn.onerror = event => {
console.error(`Error in LocalDatabase.delete for store (${table}). Query, Event:`, query, event);
reject(new Error(`Error in LocalDatabase.delete for store (${table}). Check console.`));
}
}))
}
Promise.all(deletePromises).then(resolution => success(resolution));
});
})
}
Expand Down
17 changes: 16 additions & 1 deletion LocalDatabase.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,22 @@ import DatabaseSchema from './DatabaseSchema';
// Get an array of keys from the results.
const keyArray = results.map(entry => entry[keyColumn]);
// Initiate delete

const deletePromises = [];
for(const key of keyArray) {
deletePromises.push(new Promise((delSuccess, delReject) => {
const txn = LocalDatabase.instance.transaction([tableSchema.name], "readwrite");
txn.objectStore(tableSchema.name).delete(key);

txn.oncomplete = event => {
delSuccess(event);
}
txn.onerror = event => {
console.error(`Error in LocalDatabase.delete for store (${table}). Query, Event:`, query, event);
reject(new Error(`Error in LocalDatabase.delete for store (${table}). Check console.`));
}
}))
}
Promise.all(deletePromises).then(resolution => success(resolution));
});
})
}
Expand Down

0 comments on commit 88697fa

Please sign in to comment.