I have no idea what’s wrong with this code:
onupgradeneeded = function(){
z = e.currentTarget.result.createObjectStore(
'record',
{keyPath:'id',autoIncrement:true}
);
z.createIndex('book', 'book', {unique:false});
z.createIndex('user', 'user', {unique:false});
}
When I try to put data into the object store using the following code:
db.transaction('record',IDBTransaction.READ_WRITE)
.objectStore('record')
.add({book:...,user:...})
I receive the following error message:
Data provided to an operation does not meet requirements
createIndexneeds to be called from within asetVersiontransaction (spec previous to Dec. 2011, supported by current versions of Chrome and IE) and from aonupgradeneededcallback in the latest spec (currently supported only by FF, but IE10 and later versions of Chrome will upgrade to this).The spec description of
createIndexlays out why you’re seeing the error you’re seeing:For more info on the difference between
setVersionandonupgradeneeded, check out this post from IE folks, which explains the changes in code.