From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/idbcursor/index.html | 128 ++++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 files/ja/web/api/idbcursor/index.html (limited to 'files/ja/web/api/idbcursor/index.html') diff --git a/files/ja/web/api/idbcursor/index.html b/files/ja/web/api/idbcursor/index.html new file mode 100644 index 0000000000..7b024be836 --- /dev/null +++ b/files/ja/web/api/idbcursor/index.html @@ -0,0 +1,128 @@ +--- +title: IDBCursor +slug: Web/API/IDBCursor +tags: + - API + - Database + - IDBCursor + - IndexedDB + - Interface + - NeedsTranslation + - Reference + - Storage + - TopicStub +translation_of: Web/API/IDBCursor +--- +

{{APIRef("IndexedDB")}}

+ +

IndexedDB APIIDBCursor インターフェイスはデータベースの複数レコードを横断したり繰り返すためのカーソルです。

+ +

このカーソルはどのインデックスやオブジェクトをループしているかを示す元です。これは範囲内の位置を示す持ち、レコードのキー順に増/減して動きます。カーソルはアプリケーションからカーソル範囲内の全レコードに非同期に処理できるようにします。

+ +

一度に無制限の数のカーソルを持つことができます。あるカーソルを表す同一の IDBCursor オブジェクトを取得できます。操作はインデックスやオブジェクトストアに対して実行されます。

+ +

{{AvailableInWorkers}}

+ +

プロパティ

+ +
+
{{domxref("IDBCursor.source")}} {{readonlyInline}}
+
カーソルが繰り返している{{domxref("IDBObjectStore")}} か {{domxref("IDBIndex")}} を返します。この関数は、カーソルが現在繰り返されていたり、繰り返しが終わりを過ぎたり、トランザクションがアクティブでなくても、null や例外を返しません。
+
{{domxref("IDBCursor.direction")}} {{readonlyInline}}
+
カーソルの横断の向きを返します。取りうる値については Constants を見てください。
+
{{domxref("IDBCursor.key")}} {{readonlyInline}}
+
カーソル位置のレコードのキーを返します。カーソルが範囲外の場合、undefined にセットされます。カーソルキーはあらゆるデータ型となりえます。
+
{{domxref("IDBCursor.value")}} {{readonlyInline}}
+
カーソル位置のレコードの値を返します。カーソルの値はあらゆるデータ型となりえます。
+
{{domxref("IDBCursor.primaryKey")}} {{readonlyInline}}
+
カーソルの現在有効な主キーを返します。カーソルが現在繰り返されていたり範囲外で繰り返されていた場合、これは undefined にセットされます。カーソルの主キーはあらゆるデータ型となりえます。
+
+ +

メソッド

+ +
+
{{domxref("IDBCursor.advance()")}}
+
Sets the number times a cursor should move its position forward.
+
{{domxref("IDBCursor.continue()")}}
+
Advances the cursor to the next position along its direction, to the item whose key matches the optional key parameter.
+
{{domxref("IDBCursor.continuePrimaryKey()")}}
+
Sets the cursor to the given index key and primary key given as arguments.
+
{{domxref("IDBCursor.delete()")}}
+
Returns an {{domxref("IDBRequest")}} object, and, in a separate thread, deletes the record at the cursor's position, without changing the cursor's position. This can be used to delete specific records.
+
{{domxref("IDBCursor.update()")}}
+
Returns an {{domxref("IDBRequest")}} object, and, in a separate thread, updates the value at the current position of the cursor in the object store. This can be used to update specific records.
+
+ +

Constants

+ +
{{ deprecated_header(13) }}
+ +
+

これらの constants は利用できません — Gecko 25 で削除されました。代わりに直接 string constants を使う必要があります。({{ bug(891944) }})

+
+ + + +

+ +

In this simple fragment we create a transaction, retrieve an object store, then use a cursor to iterate through all the records in the object store. The cursor does not require us to select the data based on a key; we can just grab all of it. Also note that in each iteration of the loop, you can grab data from the current record under the cursor object using cursor.value.foo. For a complete working example, see our IDBCursor example (view example live.)

+ +
function displayData() {
+  var transaction = db.transaction(['rushAlbumList'], "readonly");
+  var objectStore = transaction.objectStore('rushAlbumList');
+
+  objectStore.openCursor().onsuccess = function(event) {
+    var cursor = event.target.result;
+    if(cursor) {
+      var listItem = document.createElement('li');
+      listItem.innerHTML = cursor.value.albumTitle + ', ' + cursor.value.year;
+      list.appendChild(listItem);
+
+      cursor.continue();
+    } else {
+      console.log('Entries all displayed.');
+    }
+  };
+}
+ +

仕様

+ + + + + + + + + + + + + + +
仕様書策定状況コメント
{{SpecName('IndexedDB', '#idl-def-IDBCursor', 'cursor')}}{{Spec2('IndexedDB')}} 
+ +

ブラウザー実装状況

+ +
+ + +

{{Compat("api.IDBCursor")}}

+
+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf