Em
var stores = ['negociacoes'];
var cersion = 4;
var dbName = 'aluraframe'
class ConnectionFactory {
constructor(){
throw new Error('Não pode instanciar Connection')
}
static getConnection(){
return new Promise((resolve, reject) => {
let openRequest = windows.indexedDB.open(dbName, version);
openRequest.onupgradeneeded = e => {
ConnectionFactory._createStore(e.target.result);
}
openRequest.onsuccess = e => {
}
openRequest.onerror = e => {
}
});
}
static _createStore(connection){
stores.forEach(store => {
if (connection.ObjectStoreNames.contains(store))
connection.deleteObjectStore();
connection.createObjectStore(store, { autoIncrement: true });
})
}
}
Qual a diferença na chamada do metodo _createStore
openRequest.onupgradeneeded = e => {
ConnectionFactory._createStore(e.target.result);
}
ou
openRequest.onupgradeneeded = e => {
this._createStore(e.target.result);
}