Ive been using this code to make use of the indexedDB api. Works fine in FF 14. But in Chrome (v.21), im getting some errors. At the moment im having trouble with my createObjectStore command:
db.createObjectStore(objectStoreName, { keyPath: 'id', autoIncrement: true });
Is it because Chrome is using a different spec than FF? Does some methods still differ?
Thanks
this.init = function (successCallback) {
var openRequest = indexedDB.open(dbName);
openRequest.onupgradeneeded = function (e) {
db = e.target.result;
if (!db.objectStoreNames.contains(objectStoreName)) {
console.log('Create objectstore');
db.createObjectStore(objectStoreName, { keyPath: 'id', autoIncrement: true });
}
successCallback(e);
};
openRequest.onsuccess = function (e) {
db = e.target.result;
db.onerror = function (event) {
console.log("Database error: " + event.target.errorCode);
};
successCallback(e);
};
};
What is the error you get?
Difference between FF and chrome is that FF uses the onupgradeneeded callback and chrome the setVersion method to change the database structure