2017-01-27 10 views
0

IndexedDB objectStoreの結果と作成と人口を取り出すことができる間に、かなりの遅れがあることに気づいています。私は、多くの "put"が完了した後もインデックス作成がまだ実行されていると思われますが、各パート(createobjectStore、createIndex)を測定して戻って報告する方法はわかりません。indexeddb createIndexの成功を確認してください

作成されるインデックスの成功を簡単にチェックする方法はありますか?

request.onupgradeneeded = function(e) { 
    var db = e.target.result; 
    var partsStore = db.createObjectStore("parts", { keyPath: "classID", autoIncrement: true }); 
    partsStore.createIndex("description", "description", { unique: false }); 
} 

答えて

1

確かに、ちょうどrequestの成功イベントをリッスン。成功イベントは、アップグレード機能が完了するまで発生しません。

var request = indexedDB.open(...); 
request.onupgradeneeded = function() { 
    // create indices and whatever 
    store.createIndex(...); 
}; 

request.onsuccess = function() { 
    console.log('this shows up after the upgrade completes'); 
}; 
関連する問題