deleteObjectStore()
方法在
IDBDatabase
interface destroys the object store with the given name in the connected database, along with any indexes that reference it.
就像
IDBDatabase.createObjectStore
, this method can be called
only
在
versionchange
transaction.
dbInstance.deleteObjectStore(name);
名称
The name of the object store you want to delete.
此方法可能引发
DOMException
of one of the following types:
| 异常 | 描述 |
|---|---|
InvalidStateError
|
Occurs if the method was not called from a
versionchange
transaction callback. For older WebKit browsers, you must call first.
|
TransactionInactiveError
|
Occurs if a request is made on a source database that doesn't exist (e.g. has been deleted or removed.) In Firefox previous to version 41, an
InvalidStateError
was raised in this case as well, which was misleading; this has now been fixed (see
bug 1176165
)。
|
NotFoundError
|
You are trying to delete an object store that does not exist. Names are case sensitive. |
var dbName = "sampleDB";
var dbVersion = 2;
var request = indexedDB.open(dbName, dbVersion);
request.onupgradeneeded = function(e) {
var db = request.result;
if (e.oldVersion < 1) {
db.createObjectStore("store1");
}
if (e.oldVersion < 2) {
db.deleteObjectStore("store1");
db.createObjectStore("store2");
}
// etc. for version < 3, 4...
};
| 规范 | 状态 | 注释 |
|---|---|---|
|
索引数据库 API 2.0
The definition of 'deleteObjectStore()' in that specification. |
推荐 | |
|
索引数据库 API 草案
The definition of 'deleteObjectStore()' in that specification. |
推荐 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
deleteObjectStore
|
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
IDBDatabase
close()
createObjectStore()
deleteObjectStore()
transaction()
IDBCursor
IDBCursorSync
IDBCursorWithValue
IDBDatabaseException
IDBDatabaseSync
IDBEnvironment
IDBEnvironmentSync
IDBFactory
IDBFactorySync
IDBIndex
IDBIndexSync
IDBKeyRange
IDBObjectStore
IDBObjectStoreSync
IDBOpenDBRequest
IDBRequest
IDBTransaction
IDBTransactionSync
IDBVersionChangeEvent
IDBVersionChangeRequest