IDBDatabase: objectStoreNames property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Note: This feature is available inWeb Workers.
TheobjectStoreNames read-only property of theIDBDatabase interface is aDOMStringList containing alist of the names of theobject stores currently in the connected database.
In this article
Value
ADOMStringList containing a list ofthe names of theobject stores currentlyin the connected database.
Examples
js
// Let us open our databaseconst DBOpenRequest = window.indexedDB.open("toDoList", 4);// these two event handlers act on the database being opened successfully, or notDBOpenRequest.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);};Specifications
| Specification |
|---|
| Indexed Database API 3.0> # ref-for-dom-idbdatabase-objectstorenames①> |
Browser compatibility
See also
- 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 the example live).