Using the IndexedDB API we have these 2 methods: getAll()
and getAllKeys()
with an usage example below:
let transaction = this.db.transaction(["table"]);
let object_store = transaction.objectStore("table");
request = object_store.getAll(); /* or getAllKeys() */
request.onerror = (event) => {
console.err("error fetching data");
};
request.onsuccess = (event) => {
console.log(request.result);
};
The problem is getAll()
seems to retrieve only the data in an array format, and getAllKeys()
gets all the keys without the data. I could not find a method to get both keys and values.
Isn't there a better way of getting the data and the keys with one call, like it is stored?
If not, is there a nicer way I could do this without making the code too confusing with multiple asynchronous calls happening?
key: object
pairs. getAll() gives me only the objects, getAllKeys() gives me only the keys. I wanted a method to retrieve me both key and object (or data) without multiple async calls. – Sopping