W3cubDocs

/DOM

IDBLocaleAwareKeyRange

This is an experimental technology
Check 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 =   '&lt;td&gt;' + cursor.value.id + '&lt;/td&gt;'
                           + '&lt;td&gt;' + cursor.value.lName + '&lt;/td&gt;'
                           + '&lt;td&gt;' + cursor.value.fName + '&lt;/td&gt;'
                           + '&lt;td&gt;' + cursor.value.jTitle + '&lt;/td&gt;'
                           + '&lt;td&gt;' + cursor.value.company + '&lt;/td&gt;'
                           + '&lt;td&gt;' + cursor.value.eMail + '&lt;/td&gt;'
                           + '&lt;td&gt;' + cursor.value.phone + '&lt;/td&gt;'
                           + '&lt;td&gt;' + cursor.value.age + '&lt;/td&gt;';
      tableEntry.appendChild(tableRow);  

      cursor.continue();
    } else {
      console.log('Entries all displayed.');    
    }
  };
};

Specifications

Not currently part of any specification.

Browser compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Basic support No ? 43
Disabled
43
Disabled
Disabled From version 43: this feature is behind the dom.indexedDB.experimental preference. To change preferences in Firefox, visit about:config.
No No No
Mobile
Android webview Chrome for Android Edge Mobile Firefox for Android Opera for Android iOS Safari Samsung Internet
Basic support No No ? 43
Disabled
43
Disabled
Disabled From version 43: this feature is behind the dom.indexedDB.experimental preference. To change preferences in Firefox, visit about:config.
No No No

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/IDBLocaleAwareKeyRange