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/IDBObjectStore/count below:

IDBObjectStore: count() メソッド - Web API

IDBObjectStore: count() メソッド

Baseline Widely available

IDBObjectStore インターフェイスの count() メソッドは、IDBRequest オブジェクトを返し、別スレッドで、指定されたキーまたは IDBKeyRange にマッチするレコードの総数を返します。引数が指定されない場合は、オブジェクトストア内の全レコードの数を返します。

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

構文 引数
query 省略可

数えたいレコードの範囲を指定するキーまたは IDBKeyRange オブジェクトです。

返値

この操作に関係する今後のイベントが発火する IDBRequest オブジェクトです。

操作に成功した場合は、この要求の result プロパティの値は与えられたクエリーにマッチするレコードの数になります。

例外

このメソッドは、以下の種類のいずれかの DOMException を投げる可能性があります。

InvalidStateError DOMException

この IDBObjectStore が削除されているとき投げられます。

TransactionInactiveError DOMException

この IDBObjectStore のトランザクションが実行中でないとき投げられます。

DataError DOMException

指定されたキーまたはキー範囲が無効であるとき投げられます。

例

このシンプルな断片では、トランザクションを生成し、オブジェクトストアを取得し、count() を用いてオブジェクトストア内のレコードを数えます。success ハンドラーが実行された時、コンソールにカウント値 (整数) を記録します。

const transaction = db.transaction(["fThings"], "readonly");
const objectStore = transaction.objectStore("fThings");

const countRequest = objectStore.count();
countRequest.onsuccess = () => {
  console.log(countRequest.result);
};
仕様書 ブラウザーの互換性 関連情報

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