none
Using arrays as indexedDB keyPaths in IE 10/11

    Question

  • 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']});
    };



    Sunday, December 22, 2013 1:36 AM

Answers

  • <title>JSON strings must not be javascript literals.</title>

    validate by JSON.parse(JSON.stringify(object))

    Post questions about html, css and scripting to the IE Web Development forum with a link to your website, or to a mashup or your Complete source code.


    Rob^_^

    Monday, December 23, 2013 12:19 AM