IDBDatabase: objectStoreNames プロパティ

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2021.

objectStoreNamesIDBDatabase インターフェイスのプロパティで、現在接続しているデータベースのオブジェクトストア名のリストを含む DOMStringList です。

メモ: この機能はウェブワーカー内で利用可能です。

現在接続しているデータベースのオブジェクトストア名のリストを含む DOMStringList

js
// データベースを開く
const DBOpenRequest = window.indexedDB.open("toDoList", 4);

// これら 2 個のイベントハンドラーは、データベースが正常に開かれたか、失敗した時に動作します。
DBOpenRequest.onerror = (event) => {
  note.innerHTML += "<li>データベースの読み込みに失敗しました。</li>";
};

DBOpenRequest.onsuccess = (event) => {
  note.innerHTML += "<li>データベースを初期化しました。</li>";

  // データベースを開いた結果を変数 db に保存します。これは後でたくさん使います。
  db = DBOpenRequest.result;

  // この行では接続したデータベースのオブジェクトストア名を記録します。
  // { ['my-store-name'] } のようなオブジェクトのはずです。
  console.log(db.objectStoreNames);
};

仕様書

Specification
Indexed Database API 3.0
# ref-for-dom-idbdatabase-objectstorenames①

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
objectStoreNames

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報