aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/idbfactory/open/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/ja/web/api/idbfactory/open/index.html')
-rw-r--r--files/ja/web/api/idbfactory/open/index.html155
1 files changed, 155 insertions, 0 deletions
diff --git a/files/ja/web/api/idbfactory/open/index.html b/files/ja/web/api/idbfactory/open/index.html
new file mode 100644
index 0000000000..3946909f0b
--- /dev/null
+++ b/files/ja/web/api/idbfactory/open/index.html
@@ -0,0 +1,155 @@
+---
+title: IDBFactory.open
+slug: Web/API/IDBFactory/open
+tags:
+ - Database
+ - IDBFactory
+ - Storage
+ - open
+translation_of: Web/API/IDBFactory/open
+---
+<div>{{APIRef("IDBFactory")}}</div>
+
+<div>
+<p>{{domxref("IDBFactory")}} インターフェイスの <strong><code>open()</code></strong> メソッドは、<a href="/ja/docs/IndexedDB#gloss_database_connection">データベースへの接続</a>を開くことを要求します。</p>
+
+<p>このメソッドは即座に {{domxref("IDBOpenDBRequest")}} オブジェクトを返し、そして非同期でデータベースを開きます。操作が成功した場合、このメソッドから返される request オブジェクトに result の属性として接続のための新しい {{domxref("IDBDatabase")}} オブジェクトが設定されて、 success イベントが発生します。</p>
+</div>
+
+<p>データベースとの接続の間にエラーが発生した場合、このメソッドで返される request オブジェクトで、 <a href="/ja/docs/IndexedDB/IDBErrorEvent">error イベント</a>が発生します。</p>
+
+<p><code>upgradeneeded</code>, <code>blocked</code>, <code>versionchange</code> イベントが発生することもあります。</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="Syntax" name="Syntax">構文</h2>
+
+<p>現在の標準では:</p>
+
+<pre class="syntaxbox">var <var>IDBOpenDBRequest</var> = <var>indexedDB</var>.open(<var>name</var>);
+var <var>IDBOpenDBRequest</var> = <var>indexedDB</var>.open(<var>name</var>, <var>version</var>);
+</pre>
+
+<h3 id="Parameters" name="Parameters">引数</h3>
+
+<dl>
+ <dt>name</dt>
+ <dd>データベースの名前。</dd>
+ <dt>version {{optional_inline}}</dt>
+ <dd>省略可。データベースを開くバージョン。バージョンが提供されずにデータベースが存在した場合、データベースへの接続はバージョンを変更せずに開かれます。バージョンが提供されず、データベースも存在しなかった場合、バージョン番号 <code>1</code> が生成されます。</dd>
+</dl>
+
+<h4 id="Experimental_Gecko_options_oject" name="Experimental_Gecko_options_oject">実験的な Gecko の options オブジェクト</h4>
+
+<dl>
+ <dt>options (version および storage) {{optional_inline}} {{deprecated_inline}}</dt>
+ <dd>Gecko では、<a href="/ja/Firefox/Releases/26">バージョン 26</a> から、標準外の <code>options</code> オブジェクトを {{ domxref("IDBFactory.open") }} の引数として指定することができ、データベースの <code>version</code> 番号と、加えてストレージに <code>persistent</code> (永続的) または <code>temporary</code> (一時的) のどちらを使用したいかを指定する storage 値を指定することができます。
+ <div class="warning"><strong>警告:</strong> <code>storage</code> 属性は非推奨であり、まもなく Gecko から削除される予定です。永続的なストレージを得るには、代わりに {{domxref("StorageManager.persist()")}} を使用してください。</div>
+ </dd>
+</dl>
+
+<div class="note">
+<p><strong>メモ</strong>: 利用可能な様々なストレージ種別における詳細情報や、 Firefox がクライアント側データストレージを扱う方法については、 <a href="/ja/docs/Web/API/IndexedDB_API/Browser_storage_limits_and_eviction_criteria">ブラウザーのストレージ制限と削除基準</a>で見つけることができます。</p>
+</div>
+
+<h3 id="Return_value" name="Return_value">返値</h3>
+
+<p>この要求に関連のある連続したイベントが発生する {{domxref("IDBOpenDBRequest")}} オブジェクト。</p>
+
+<h3 id="Exceptions" name="Exceptions">例外</h3>
+
+<p>このメソッドは、次の型のような <a href="/ja/docs/DOM/DOMError">DOMError</a> を持つ {{domxref("DOMException")}} が発生する可能性があります。</p>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">例外</th>
+ <th scope="col">説明</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><code>TypeError</code></td>
+ <td>バージョンの値がゼロかマイナスの値、または数値でない場合。</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Example" name="Example">例</h2>
+
+<p><code>open</code> を現在の仕様書の <code>version</code> 引数を付けて呼び出す例です。</p>
+
+<pre class="brush: js">var request = window.indexedDB.open("toDoList", 4);</pre>
+
+<p>次のコードスニペットは、データベースを開く要求をして、成功の場合と失敗の場合のイベントハンドラを登録しています。完璧に動作する例は、 <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> app (<a class="external" href="http://mdn.github.io/to-do-notifications/">view example live</a>.) を見てください。</p>
+
+<pre class="brush:js">var note = document.querySelector("ul");
+
+// In the following line, you should include the prefixes
+// of implementations you want to test.
+window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
+// DON'T use "var indexedDB = ..." if you're not in a function.
+// Moreover, you may need references to some window.IDB* objects:
+window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
+window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
+// (Mozilla has never prefixed these objects, so we don't
+// need window.mozIDB*)
+
+// Let us open version 4 of our database
+var DBOpenRequest = window.indexedDB.open("toDoList", 4);
+
+// these two event handlers act on the database being opened
+// successfully, or not
+DBOpenRequest.onerror = function(event) {
+ note.innerHTML += '&lt;li&gt;Error loading database.&lt;/li&gt;';
+};
+
+DBOpenRequest.onsuccess = function(event) {
+ note.innerHTML += '&lt;li&gt;Database initialised.&lt;/li&gt;';
+
+ // store the result of opening the database in the db
+ // variable. This is used a lot later on, for opening
+ // transactions and suchlike.
+ db = DBOpenRequest.result;
+};
+</pre>
+
+<h2 id="Specifications" name="Specifications">仕様書</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">仕様書</th>
+ <th scope="col">状態</th>
+ <th scope="col">備考</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('IndexedDB', '#widl-IDBFactory-open-IDBOpenDBRequest-DOMString-name-unsigned-long-long-version', 'open()')}}</td>
+ <td>{{Spec2('IndexedDB')}}</td>
+ <td> </td>
+ </tr>
+ <tr>
+ <td>{{SpecName("IndexedDB 2", "#dom-idbfactory-open", "open()")}}</td>
+ <td>{{Spec2("IndexedDB 2")}}</td>
+ <td> </td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの対応</h2>
+
+<p class="hidden">このページの互換性一覧表は構造化データから生成されています。データに協力していただけるのであれば、 <a class="external" href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> をチェックアウトしてプルリクエストを送信してください。</p>
+
+<p>{{Compat("api.IDBFactory.open")}}</p>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li><a href="/ja/docs/Web/API/IndexedDB_API/Using_IndexedDB">Using IndexedDB</a></li>
+ <li>Starting transactions: {{domxref("IDBDatabase")}}</li>
+ <li>Using transactions: {{domxref("IDBTransaction")}}</li>
+ <li>Setting a range of keys: {{domxref("IDBKeyRange")}}</li>
+ <li>Retrieving and making changes to your data: {{domxref("IDBObjectStore")}}</li>
+ <li>Using cursors: {{domxref("IDBCursor")}}</li>
+ <li>Reference example: <a class="external" href="https://github.com/mdn/to-do-notifications/tree/gh-pages">To-do Notifications</a> (<a class="external" href="http://mdn.github.io/to-do-notifications/">view example live</a>.)</li>
+</ul>