IndexedDB bug
by slace
JavaScript
(function (window) {
var indexedDB = window.indexedDB || window.msIndexedDB || window.webkitIndexedDB || window.mozIndexedDB,
IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
var req = indexedDB.open('test', 1);
req.onupgradeneeded = function (e) {
console.log('upgrade time');
var db = e.target.result;
db.createObjectStore('items', { keyPath: 'id', autoIncrement: true });
};
req.onsuccess = function (e) {
console.log('success!');
var db = e.target.result;
console.log('object stores in db' , db.objectStoreNames);
try {
var transaction = db.transaction(['items'], IDBTransaction.READ_WRITE);
} catch (e) {
console.log('error making transaction', e);
return;
}
var store = transaction.objectStore('items');
var req = store.add({ firstName: 'Aaron', lastName: 'Powell' });
req.onsuccess = function (e) {
console.log('added!', e);
};
req.onerror = function (e) { console.log('error!', e); };
req.deleteDatabase('test');
};
})( window );