A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/ja/docs/Web/API/IDBRequest/source below:

IDBRequest.source - Web API | MDN

IDBRequest.source

Baseline Widely available

IDBRequest インターフェイスの読み取り専用プロパティ source は、要求元 (インデックスやオブジェクトストアなど) を返します。(IDBFactory.open を呼んだときなど) 要求元が存在しない場合、null を返します。

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

値

IDBIndex、IDBObjectStore、IDBCursor などの、要求元を表すオブジェクトです。

例

以下の例では、タイトルを指定してレコードを要求し、onsuccess で IDBObjectStore から (objectStoreTitleRequest.result として参照できるようになった) 対応するレコードを取得し、レコードのプロパティ 1 個を更新し、更新したレコードを別の要求でオブジェクトストアに書き戻します。2 番目の要求の要求元が、開発者コンソールに記録されます。動く例全体は、To-do Notifications アプリケーションを参照してください。(動く例を見る)

const title = "Walk dog";

// 通常通りトランザクションを開始します
const objectStore = db
  .transaction(["toDoList"], "readwrite")
  .objectStore("toDoList");

// 指定した title をタイトルとして持つ TO-DO リストのオブジェクトを取得します
const objectStoreTitleRequest = objectStore.get(title);

objectStoreTitleRequest.onsuccess = () => {
  // result として返されたデータオブジェクトを取得します
  const data = objectStoreTitleRequest.result;

  // オブジェクトの notified の値を "yes" に更新します
  data.notified = "yes";

  // アイテムをデータベースに書き戻す別の要求を生成します
  const updateTitleRequest = objectStore.put(data);

  // この要求の要求元を記録します
  console.log(`この要求の要求元は ${updateTitleRequest.source} です`);
  // 新しい要求が成功したら、また displayData() 関数を
  // 実行し、表示を更新します
  updateTitleRequest.onsuccess = () => {
    displayData();
  };
};
仕様書 ブラウザーの互換性 関連情報

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4