IDBDatabase: objectStoreNames 屬性
注意:此功能在 Web Workers 中可用。
IDBDatabase 介面的 objectStoreNames 只讀屬性是一個 DOMStringList,其中包含當前連線的資料庫中物件倉庫名稱的列表。
值
一個 DOMStringList,其中包含當前連線的資料庫中物件倉庫名稱的列表。
示例
js
// Let us open our database
const DBOpenRequest = window.indexedDB.open("toDoList", 4);
// these two event handlers act on the database being opened successfully, or not
DBOpenRequest.onerror = (event) => {
note.appendChild(document.createElement("li")).textContent =
"Error loading database.";
};
DBOpenRequest.onsuccess = (event) => {
note.appendChild(document.createElement("li")).textContent =
"Database initialized.";
// store the result of opening the database in the db variable. This is used a lot below
db = DBOpenRequest.result;
// This line will log the names of the object stores of the connected database, which should be
// an object that looks like { ['my-store-name'] }
console.log(db.objectStoreNames);
};
規範
| 規範 |
|---|
| Indexed Database API 3.0 # ref-for-dom-idbdatabase-objectstorenames① |
瀏覽器相容性
載入中…
另見
- 使用 IndexedDB
- 開始事務:
IDBDatabase - 使用事務:
IDBTransaction - 設定鍵的範圍:
IDBKeyRange - 檢索和修改資料:
IDBObjectStore - 使用遊標:
IDBCursor - 參考示例:待辦事項通知(檢視即時示例)。