I have a store in IndexDB which called PendingFile
var pendingFileTable = db.createObjectStore("pendingfile", {keyPath: ['serverid', 'hash', 'segment']});
Now, i have 50 PendingFiles that they have the same (ServerId, Hash) and segment is from 1..50. Now i want to delete all of them by one transaction and one Delete operation using the IDBKeyRange.
So i do the following
export async function deleteByIds(collectionName, indexName, serverId, hash, totalSegments) {
let request = new Promise((resolve) => {
let myDatabase = indexedDB.open(DATABASE_NAME, CURRENT_VERSION);
myDatabase.onsuccess = function () {
let lower = [serverId, hash, 1];
let upper = [serverId, hash, totalSegments];
let range = IDBKeyRange.bound(lower, upper, false, false);
let transaction = myDatabase.result.transaction(collectionName, 'readwrite');
transaction.objectStore(collectionName).delete(range).onsuccess = (event) => {
resolve(event);
};
}
});
let result = await request;
return result;
}
However, after the function call i see that the PendingFile still has the entities on it. What do i do wrong?