IDBKeyRange.lowerOpen

IDBKeyRange インターフェイスの読み取り専用プロパティ lowerOpen は、下限の値がキーの範囲に含まれるかを表す boolean 値を返します。

注: この機能は Web Worker 内で利用可能です。

boolean 値です。

意味
true 下限の値はキーの範囲に含まれません。
false 下限の値はキーの範囲に含まれます。

以下の例は、キーの範囲の使用法を示します。keyRangeValue = IDBKeyRange.upperBound("F", "W", true, true); と宣言します。上限と下限の両方が開 (true) として宣言されているので、これは "F""W" の間の値を全て含むが、これらの値は含まない範囲です。(IDBTransaction により) トランザクションを開き、オブジェクトストアを開き、省略可能なキーの範囲の値を keyRangeValue として IDBObjectStore.openCursor でカーソルを開きます。

キーの範囲を宣言した後、その lowerOpen プロパティの値をコンソールに記録します。これは "true" になるはずです。下限は開なので、範囲には含まれないでしょう。

メモ: キーの範囲に関する実験ができるより完全な例は、IDBKeyRange-example レポジトリを参照してください。(動く例も見る)

js
function displayData() {
  const keyRangeValue = IDBKeyRange.bound("F", "W", true, true);
  console.log(keyRangeValue.lowerOpen);

  const transaction = db.transaction(["fThings"], "readonly");
  const objectStore = transaction.objectStore("fThings");
  objectStore.openCursor(keyRangeValue).onsuccess = (event) => {
    const cursor = event.target.result;
    if (cursor) {
      const listItem = document.createElement("li");
      listItem.textContent = `${cursor.value.fThing}, ${cursor.value.fRating}`;
      list.appendChild(listItem);
      cursor.continue();
    } else {
      console.log("全エントリーを表示しました。");
    }
  };
}

仕様書

Specification
Indexed Database API 3.0
# ref-for-dom-idbkeyrange-loweropen①

ブラウザーの互換性

BCD tables only load in the browser

関連情報