IDBRecord
Note: This feature is available in Web Workers.
The IDBRecord interface of the IndexedDB API represents a snapshot of a single record in an IDBObjectStore or IDBIndex.
A request for records using IDBObjectStore.getAllRecords() or IDBIndex.getAllRecords() returns an IDBRequest instance.
On success the returned object's result property is populated with an array of IDBRecord instances.
Instance properties
keyRead only-
A value representing the record's key. For an object store record this will be the same as
primaryKey. For an index record it will be the record's key within the index. primaryKeyRead only-
A value representing the key of the record in the index's associated
IDBObjectStore. valueRead only-
A value representing the record's value.
Instance methods
None.
Example
In the following code snippet, we open a database asynchronously and make a request; onerror and onsuccess functions are included to handle the success and error cases.
For a full working example, see our To-do Notifications app (view example live.)
const query = IDBKeyRange.lowerBound("myKey", true);
const objectStore = transaction.objectStore("contactsList");
const myRecords = (objectStore.getAllRecords({
query,
count: "100",
direction: "prev",
}).onsuccess = (event) => {
console.log(myRecords.result); // Array of IDBRecord instances
});
Specifications
| Specification |
|---|
| Indexed Database API 3.0> # record-interface> |