var myDB={
name:"univisity",
version:1,
db:null,
ojstore:{
name:"students",//
keypath:"id"//
}
};
var INDEXDB = {
indexedDB:window.indexedDB||window.webkitindexedDB,
IDBKeyRange:window.IDBKeyRange || window.webkitIDBKeyRange,//
openDB:function(dbname,dbversion,callback){
//(ObjectStore)
var self = this;
var version = dbversion || 1;
var request = self.indexedDB.open(dbname,version);
request.onerror = function(e){
console.log(e.currentTarget.error.message);
};
request.onsuccess = function(e){
myDB.db = e.target.result;
console.log(":"+myDB.name+" version"+dbversion);
};
request.onupgradeneeded=function(e){
var db=e.target.result,transaction= e.target.transaction,store;
if(!db.objectStoreNames.contains(myDB.ojstore.name)){
//
store = db.createObjectStore(myDB.ojstore.name,{keyPath:myDB.ojstore.keypath});
console.log(":"+myDB.ojstore.name);
}
}
}
}
INDEXDB.addData(myDB.db,myDB.ojstore.name,students);
just looked at the indexDb, above code initialization page to create a storage space for univisity in indexdb, and create a data table for students in this space. I want to create another data table for teachers. How should I write it?