deleteDatabase()
方法在
IDBFactory
interface requests the deletion of a database. The method returns an
IDBOpenDBRequest
object immediately, and performs the deletion operation asynchronously.
If the database is successfully deleted, then a
success
event is fired on the request object returned from this method, with its
result
设为
undefined
. If an error occurs while the database is being deleted, then an
error
event is fired on the request object that is returned from this method.
当
deleteDatabase()
is called, any other open connections to this particular database will get a
versionchange
事件。
For the current standard:
var request = indexedDB.deleteDatabase(name);
For the experimental version with
选项
(see below):
var request = indexedDB.deleteDatabase(name, options);
IDBDatabase.deleteObjectStore()
, which does throw an exception if the named object store does not exist.
permanent
(the default value) IndexedDB, or an indexedDB in
temporary
storage (aka shared pool.)
A
IDBOpenDBRequest
on which subsequent events related to this request are fired.
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(event.result); // should be undefined
};
| 规范 | 状态 | 注释 |
|---|---|---|
|
索引数据库 API 草案
The definition of 'deleteDatabase()' in that specification. |
推荐 | |
|
索引数据库 API 2.0
The definition of 'deleteDatabase()' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
deleteDatabase
|
Chrome
24
|
Edge 12 |
Firefox
16
|
IE 部分支持 10 | Opera 15 | Safari 7 |
WebView Android
Yes
|
Chrome Android 25 | Firefox Android 22 | Opera Android 14 | Safari iOS 8 | Samsung Internet Android 1.5 |
完整支持
部分支持
要求使用供应商前缀或不同名称。
IDBDatabase
IDBTransaction
IDBKeyRange
IDBObjectStore
IDBCursor
IDBFactory
IDBCursor
IDBCursorSync
IDBCursorWithValue
IDBDatabase
IDBDatabaseException
IDBDatabaseSync
IDBEnvironment
IDBEnvironmentSync
IDBFactorySync
IDBIndex
IDBIndexSync
IDBKeyRange
IDBObjectStore
IDBObjectStoreSync
IDBOpenDBRequest
IDBRequest
IDBTransaction
IDBTransactionSync
IDBVersionChangeEvent
IDBVersionChangeRequest