This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.
The IDBLocaleAwareKeyRange
interface of the IndexedDB API is a Firefox-specific version of IDBKeyRange
— it functions in exactly the same fashion, and has the same properties and methods, but it is intended for use with IDBIndex
objects when the original index had a locale
value specified upon its creation (see createIndex()
's optionalParameters) — that is, it has locale aware sorting enabled.
Methods
This interface inherits all the methods of its parent interface, IDBKeyRange
.
Properties
This interface inherits all the properties of its parent interface, IDBKeyRange
.
Bear in mind however that IDBLocaleAwareKeyRange
has its own implementation of IDBKeyRange.bound
. This is because when you use bound()
, it checks if lower bound < upper bound, and throws an exception if that’s not the case. With locale-aware indexes, the meaning of < depends on the locale, so for example in Lithuanian Y is sorted between I and K. The only difference between IDBKeyRange
and IDBLocaleAwareKeyRange
is that the latter doesn’t do the aforementioned check.
Developers should always use IDBLocaleAwareKeyRange
when dealing with locale-aware indexes.
Examples
function displayData() {
var keyRangeValue = IDBLocaleAwareKeyRange.bound("A", "F");
var transaction = db.transaction(['fThings'], 'readonly');
var objectStore = transaction.objectStore('fThings');
var myIndex = objectStore.index('lName');
myIndex.openCursor(keyRangeValue).onsuccess = function(event) {
var cursor = event.target.result;
if(cursor) {
var tableRow = document.createElement('tr');
tableRow.innerHTML = '<td>' + cursor.value.id + '</td>'
+ '<td>' + cursor.value.lName + '</td>'
+ '<td>' + cursor.value.fName + '</td>'
+ '<td>' + cursor.value.jTitle + '</td>'
+ '<td>' + cursor.value.company + '</td>'
+ '<td>' + cursor.value.eMail + '</td>'
+ '<td>' + cursor.value.phone + '</td>'
+ '<td>' + cursor.value.age + '</td>';
tableEntry.appendChild(tableRow);
cursor.continue();
} else {
console.log('Entries all displayed.');
}
};
};
Specifications
Not currently part of any specification.
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
No support No |
Edge
No support No |
Firefox Full support 43 Full support 43 Disabled' From version 43: this feature is behind the |
IE
No support No |
Opera
No support No |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android Full support 43 Full support 43 Disabled' From version 43: this feature is behind the |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.'
- Non-standard. Expect poor cross-browser support.
- User must explicitly enable this feature.'
- User must explicitly enable this feature.
See also
- Using IndexedDB
- Starting transactions:
IDBDatabase
- Using transactions:
IDBTransaction
- Setting a range of keys:
IDBKeyRange
- Retrieving and making changes to your data:
IDBObjectStore
- Using cursors:
IDBCursor
- Reference example: To-do Notifications ([[../../../../../../mdn.github.io/to-do-notifications/index|view example live]].)
IDBLocaleAwareKeyRange by Mozilla Contributors is licensed under CC-BY-SA 2.5.