const tx = db.transaction("books", "readonly"); const store = tx.objectStore("books"); const index = store.index("by_author"); const request = index.openCursor(IDBKeyRange.only("Fred")); request.onsuccess = function() { const cursor = request.result; if (cursor) { // Called for each matching record. report(cursor.value.isbn, cursor.value.title, cursor.value.author); cursor.continue(); } else { // No more matching records. report(null); } };
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter