IndexedDB - DataError: Data provided to an operation does not meet requirements

Viewed 7773

I've looked at other similar questions. My case is different because I am inserting simple json objects with no keys, no auto increment.

Here's the part that does the insert:

function insertInto(model, data, successCallback) {
    console.log("inserting into model "+model); 
    var transaction = db.transaction([model], IDBTransaction.READ_WRITE || 'readwrite');
    var store, i, request;
    var total = data.length;

    function successCallbackInner() {
        total = total - 1;
        if (total === 0) {
            successCallback();
        }
    }
    transaction.onerror = indexedDBError;
    store = transaction.objectStore(model);
    for (i in data) {
        if (data.hasOwnProperty(i)) {
            console.log(data[i]);
            request = store.add(data[i]);
            request.onsuccess = successCallbackInner;
            request.onerror = indexedDBError;
        }
    }
}

The error is DataError: Data provided to an operation does not meet requirements.

When I log the data I'm trying to insert it confirms my object is a simple object with three string parameters: Object { cooked="well done", cheese="provolone", toasted="no"}

Here is a jsFiddle with the full testing code.

Any and all suggestions are appreciated. Even "try this" replies. I've been trying to figure this out since yesterday morning.

Thank you

1 Answers
Related