Unless boundKeyRange
is used later, you're not missing something. IDBKeyRange.only
just creates an IDBKeyRange
object, and if that object isn't used in some IndexedDB request, it does absolutely nothing.
Google Chrome Indexdb - redundant code
-
10-10-2022 - |
Question
I am tryint yo understand some code from an opensource project that handles indexDB commands within a Google Chrome application.
The code is as follows :
var db = pm.indexedDB.db;
var trans = db.transaction([pm.indexedDB.TABLE_DRIVE_CHANGES], "readwrite");
var store = trans.objectStore(pm.indexedDB.TABLE_DRIVE_CHANGES);
var boundKeyRange = IDBKeyRange.only(driveChange.id);
var request = store.put(driveChange);
request.onsuccess = function (e) {
callback(driveChange);
};
request.onerror = function (e) {
console.log(e.value);
};
Although the app works, to me it seems that the following line is redundant code
var boundKeyRange = IDBKeyRange.only(driveChange.id);
Or am I missing something? The variable 'boundKeyRange' is never referenced anywhere.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow