chromeで使用するためにindexeddbストレージを設定しようとしています。しかし、READ_WRITE
トランザクションを設定しようとするとUncaught TypeError
が表示されます。Uncaught TypeError:indexedDBを使用しているときにChromeでエラーが発生しました
私はwebkitIDBの使用に関する最新の情報を見つけることができませんでした。だから私は基本的にここで盲目的に飛んでいる私が間違っていたことは何ですか?私が逃したのは、そこに良い靴がありますか?
セットアップ:
function OfflineStorage() {
this.saveJSONString = __bind(this.saveJSONString, this);
var request,
_this = this;
this.dbkeyRange = window.webkitIDBKeyRange;
this.dbTransaction = window.webkitIDBTransaction;
this.db = window.webkitIndexedDB;
request = this.db.open("lucidFrog");
request.onsuccess = function(e) {
_this.db = e.target.result;
return _this.setupDB(); //setupDB() ensures the objectStores have been created.
};
}
セーブ機能:
OfflineStorage.prototype.saveJSONString = function(objectStore, json_string, obj_id) {
var request, store, transaction;
//PROBLEM AREA, gives "Uncaught TypeError: Type error"
transaction = this.db.transaction([objectStore], this.dbTransaction.READ_WRITE, 0);
////////////////////
store = transaction.objectStore(objectStore);
request = store.put({
"json": json_string,
"id": obj_id
});
request.onsuccess = function(e) {
return console.log("YYYYYYEEEEEAAAAAHHHHHH!!!");
};
};
要求objectStore
が作成され、this.dbTransaction
が定義されていることが確認されています。
私は自分自身をIndexedDBの "エキスパート"と思っています。私は喜んで支援します。最初に、オブジェクトストアの作成時に返される文字列や参照など、実際のオブジェクトストアへの参照を渡す 'objectStore' varがありますか? – buley
'objectStore'が文字列として渡されています。 –