// Create a transaction on the database and use it to get the contained store
const transaction = db.transaction(["contactsList"], "readonly");
const objectStore = transaction.objectStore("contactsList");
const query = IDBKeyRange.lowerBound("myKey", true);
const request = objectStore.getAllRecords({
query,
count: 100,
direction: "prev",
});
request.addEventListener("success", (event) => {
const myRecords = event.target.result; // Array of IDBRecord instances
console.log(myRecords);
});
request.addEventListener("error", (event) => {
console.error("Error retrieving records:", event.target.error);
});IDBObjectStore: getAllRecords() method / notebook
IDBObjectStore: getAllRecords() method
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.