const transaction = db.transaction("name", "readonly");
const objectStore = transaction.objectStore("name");
const request = objectStore.openKeyCursor();
request.onsuccess = (event) => {
const cursor = event.target.result;
if (cursor) {
// cursor.key contains the key of the current record being iterated through
// note that there is no cursor.value, unlike for openCursor
// this is where you'd do something with the result
cursor.continue();
} else {
// no more results
}
};IDBObjectStore: openKeyCursor() method / notebook
IDBObjectStore: openKeyCursor() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.