IDBFactory
インターフェイスのdeleteDatabase()
メソッドは、データベースの削除を要求します。 このメソッドは直ちにIDBOpenDBRequest
オブジェクトを返し、非同期でデータベースの削除処理を行います。
データベースの削除が成功した場合、 このメソッドから返されたrequestオブジェクトにおいて、resultにnullが設定された状態でsuccessイベントが発生します。 データベースの削除中にエラーが発生した場合、このメソッドから返されたrequestオブジェクトで、errorイベントが発生します。
構文
現在の標準:
var request = window.indexedDB.deleteDatabase("toDoList");
オプション付の実験バージョン
(下を見てください):
var request = window.indexedDB.deleteDatabase("toDoList", storage: "temporary");
戻り値
この要求に関連のある連続したイベントが発生するIDBOpenDBRequest
。
例
var DBDeleteRequest = window.indexedDB.deleteDatabase("toDoList");
DBDeleteRequest.onerror = function(event) {
console.log("Error deleting database.");
};
DBDeleteRequest.onsuccess = function(event) {
console.log("Database deleted successfully");
console.log(request.result); // should be null
};
パラメーター
- name
- データベース名
- options 非標準
- Geckoのversion 26から、永続的な(既定値)IndexedDBまたは、一時的なストレージ(shared pool)を削除するための、標準化されていないオプションのストレージパラメーターを含めることができます。
Note: Data in temporary storage persists until the global limit for the pool is reached. The global limit calculation is relatively complex, but we are considering changing it (see バグ 968272). When the global limit is reached, then data for the least recently used origin is deleted. There's also a group limit (eTLD+1 group/domain) which is currently 20% of the global limit. All requests that would exceed the group limit are just rejected.
仕様
Specification | Status | Comment |
---|---|---|
Indexed Database API deleteDatabase の定義 |
勧告 |
ブラウザ実装状況
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 23webkit 24 |
10 moz 16.0 (16.0) |
10, partial | 15 | 7.1 |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 4.4 | 22.0 (22.0) | 1.0.1 | 10 | 22 | 未サポート |
Chromeは新しい仕様を実装していますが、旧い仕様も実装したままになっているので注意してください。同じように、ベンダプレフィックスなしのindexedDBがあるにもかかわらず、プレフィックス付きのwebkitIndexedDBも実装しています。
関連情報
- Using IndexedDB
- Starting transactions:
IDBDatabase
- Using transactions:
IDBTransaction
- Setting a range of keys:
IDBKeyRange
- Retrieving and making changes to your data:
IDBObjectStore
- Using cursors:
IDBCursor
- Reference example: To-do Notifications (view example live.)