Quantcast
Viewing all articles
Browse latest Browse all 10469

Using arrays as indexedDB keyPaths in IE 10/11

I'm having troubles using an array as a keyPath on my indexedDB objectStores. How can I get this working so I can enforce double keys?

The following code throws a DataError when trying to put.

var request = window.indexedDB.open("MyTestDatabase");

request.onsuccess = function(event) {
    var database = event.target.result;
    var transaction = database.transaction(["document"], "readwrite");
    var objectStore = transaction.objectStore("document");
    var request = objectStore.put({title: 'MyDoc', version: 0});
    request.onsuccess = function() {
        console.log('document added');
    };
    request.error = function(error) {
        console.log(JSON.stringify(error));
    };                
    transaction.oncomplete = function() {
        console.log('transaction complete');
    };
    transaction.onerror = function(error) {
        console.log(JSON.stringify(error));
    };
};

request.onupgradeneeded = function(event) {
    event.target.result.createObjectStore("document", {keyPath: ['title', 'version']});
};




Viewing all articles
Browse latest Browse all 10469

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>