Reputation: 59
can someone please tell me where im going wrong here?
window.indexedDB = window.indexedDB || window.webkitIndexedDB ||
window.mozIndexedDB;
if ('webkitIndexedDB' in window) {
window.IDBTransaction = window.webkitIDBTransaction;
window.IDBKeyRange = window.webkitIDBKeyRange;
}
var VULY_DB = {};
VULY_DB = {};
VULY_DB.db = null;
VULY_DB.onerror = function(e) {
console.log(e);
};
VULY_DB.open = function() {
var request = indexedDB.open(salt);
request.onerror = request.onsuccess = function(e) { VULY_DB.onerror(request.error); };
request.onsuccess = function(e) {
VULY_DB.db = e.target.result;
var db = VULY_DB.db;
var store = db.createObjectStore("revisions", {keyPath: "id"});
};
};
VULY_DB.open();
Thank you!
Upvotes: 0
Views: 1069
Reputation: 18690
You also generally do not need to use prefixed globals. I believe in recent versions of Chrome the -webkit prefix was dropped and you should just use the normal global variable.
Upvotes: 2
Reputation: 880
You need to create objectStores in an onupgradeneeded method, not onsuccess.
See MDN's example under "Structuring the database":
https://developer.mozilla.org/en-US/docs/IndexedDB/Using_IndexedDB
Upvotes: 6