aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/idbtransaction/complete_event/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/idbtransaction/complete_event/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/api/idbtransaction/complete_event/index.html')
-rw-r--r--files/ja/web/api/idbtransaction/complete_event/index.html130
1 files changed, 130 insertions, 0 deletions
diff --git a/files/ja/web/api/idbtransaction/complete_event/index.html b/files/ja/web/api/idbtransaction/complete_event/index.html
new file mode 100644
index 0000000000..2ff4900ce7
--- /dev/null
+++ b/files/ja/web/api/idbtransaction/complete_event/index.html
@@ -0,0 +1,130 @@
+---
+title: complete
+slug: Web/API/IDBTransaction/complete_event
+tags:
+ - Event
+ - IDBTransaction
+ - Reference
+ - complete
+ - イベント
+translation_of: Web/API/IDBTransaction/complete_event
+---
+<div>{{APIRef("IndexedDB")}}</div>
+
+<p><code>complete</code> イベントはトランザクションが成功裏に終了した場合に発生します。</p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row">バブリング</th>
+ <td>なし</td>
+ </tr>
+ <tr>
+ <th scope="row">キャンセル</th>
+ <td>不可</td>
+ </tr>
+ <tr>
+ <th scope="row">インターフェイス</th>
+ <td>{{DOMxRef("Event")}}</td>
+ </tr>
+ <tr>
+ <th scope="row">イベントハンドラープロパティ</th>
+ <td>{{DOMxRef("IDBTransaction.oncomplete", "oncomplete")}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Examples" name="Examples">例</h2>
+
+<p>{{DOMxRef("EventTarget.addEventListener", "addEventListener()")}} を使用:</p>
+
+<pre class="brush: js;">// データベースを開く
+const DBOpenRequest = window.indexedDB.open('toDoList', 4);
+
+DBOpenRequest.onupgradeneeded = event =&gt; {
+ const db = event.target.result;
+
+ db.onerror = () =&gt; {
+ console.log('Error creating database');
+ };
+
+ // このデータベースの objectStore を作成
+ var objectStore = db.createObjectStore('toDoList', { keyPath: 'taskTitle' });
+
+ // define what data items the objectStore will contain
+ objectStore.createIndex('hours', 'hours', { unique: false });
+ objectStore.createIndex('minutes', 'minutes', { unique: false });
+ objectStore.createIndex('day', 'day', { unique: false });
+ objectStore.createIndex('month', 'month', { unique: false });
+ objectStore.createIndex('year', 'year', { unique: false });
+};
+
+DBOpenRequest.onsuccess = event =&gt; {
+ const db = DBOpenRequest.result;
+
+ // DB の読み書きトランザクションを開き、データを追加する準備ができる
+ const transaction = db.transaction(['toDoList'], 'readwrite');
+
+ // `complete` のためのリスナーを追加
+ transaction.addEventListener('complete', event =&gt; {
+ console.log('Transaction was competed');
+ });
+
+ const objectStore = transaction.objectStore('toDoList');
+ const newItem = { taskTitle: 'my task', hours: 10, minutes: 10, day: 10, month: 'January', year: 2019 };
+ const objectStoreRequest = objectStore.add(newItem);
+};
+
+</pre>
+
+<p>{{DOMxRef("IDBTransaction.oncomplete", "oncomplete")}} プロパティを使用:</p>
+
+<pre class="brush: js;">// データベースを開く
+const DBOpenRequest = window.indexedDB.open('toDoList', 4);
+
+DBOpenRequest.onupgradeneeded = event =&gt; {
+ const db = event.target.result;
+
+ db.onerror = () =&gt; {
+ console.log('Error creating database');
+ };
+
+ // このデータベースの objectStore を作成
+ var objectStore = db.createObjectStore('toDoList', { keyPath: 'taskTitle' });
+
+ // objectStore がどのようなデータアイテムを含むかを定義
+ objectStore.createIndex('hours', 'hours', { unique: false });
+ objectStore.createIndex('minutes', 'minutes', { unique: false });
+ objectStore.createIndex('day', 'day', { unique: false });
+ objectStore.createIndex('month', 'month', { unique: false });
+ objectStore.createIndex('year', 'year', { unique: false });
+};
+
+DBOpenRequest.onsuccess = event =&gt; {
+ const db = DBOpenRequest.result;
+
+ // DB の読み書きトランザクションを開き、データを追加する準備ができる
+ const transaction = db.transaction(['toDoList'], 'readwrite');
+
+ // `complete` のためのリスナーを追加
+ transaction.oncomplete = event =&gt; {
+ console.log('Transaction was competed');
+ };
+
+ const objectStore = transaction.objectStore('toDoList');
+ const newItem = { taskTitle: 'my task', hours: 10, minutes: 10, day: 10, month: 'January', year: 2019 };
+ const objectStoreRequest = objectStore.add(newItem);
+};</pre>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
+
+<div class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</div>
+
+<p>{{Compat("api.IDBTransaction.complete_event")}}</p>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li><a href="/ja/docs/IndexedDB/Using_IndexedDB">IndexedDB の使用</a></li>
+ <li>{{DOMxRef("IDBTransaction.oncomplete", "oncomplete")}} イベントハンドラープロパティ</li>
+</ul>