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/idbdatabase/close/index.html | 131 +++++++++++++ .../api/idbdatabase/createobjectstore/index.html | 209 +++++++++++++++++++++ files/ja/web/api/idbdatabase/index.html | 196 +++++++++++++++++++ files/ja/web/api/idbdatabase/name/index.html | 115 ++++++++++++ .../api/idbdatabase/objectstorenames/index.html | 115 ++++++++++++ files/ja/web/api/idbdatabase/version/index.html | 114 +++++++++++ 6 files changed, 880 insertions(+) create mode 100644 files/ja/web/api/idbdatabase/close/index.html create mode 100644 files/ja/web/api/idbdatabase/createobjectstore/index.html create mode 100644 files/ja/web/api/idbdatabase/index.html create mode 100644 files/ja/web/api/idbdatabase/name/index.html create mode 100644 files/ja/web/api/idbdatabase/objectstorenames/index.html create mode 100644 files/ja/web/api/idbdatabase/version/index.html (limited to 'files/ja/web/api/idbdatabase') diff --git a/files/ja/web/api/idbdatabase/close/index.html b/files/ja/web/api/idbdatabase/close/index.html new file mode 100644 index 0000000000..12a2046a30 --- /dev/null +++ b/files/ja/web/api/idbdatabase/close/index.html @@ -0,0 +1,131 @@ +--- +title: IDBDatabase.close +slug: Web/API/IDBDatabase/close +tags: + - API + - Database + - IDBDatabase + - IndexedDB + - Method + - Storage + - close +translation_of: Web/API/IDBDatabase/close +--- +

{{ APIRef("IDBDatabase") }}

+ +
+

{{domxref("IDBDatabase")}}インターフェイスのclose()は、ただちに戻り、別スレッドで接続を閉じます。

+
+ +

実際には、この接続を使用していて生成されたすべてのトランザクションが完了するまで、接続は閉じられません。一度このメソッドが呼び出されたら、この接続では、新しいトランザクションを生成することはできません。終了処理がペンディングされている場合は、トランザクションを生成するメソッドは、例外を発生させます。

+ +

構文

+ +
db.close();
+ +

戻り値

+ +

Void。

+ +

+ +
// Let us open 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 += '<li>Error loading database.</li>';
+  };
+
+  DBOpenRequest.onsuccess = function(event) {
+    note.innerHTML += '<li>Database initialised.</li>';
+
+    // store the result of opening the database in the db variable.
+    db = DBOpenRequest.result;
+
+    // now let's close the database again!
+    db.close();
+  }
+ +

仕様

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IndexedDB', '#widl-IDBDatabase-close-void', 'close()')}}{{Spec2('IndexedDB')}} 
+ +

ブラウザ実装状況

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support23{{property_prefix("webkit")}}
+ 24
10 {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16.0")}}
10, partial157.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support4.4{{CompatGeckoMobile("22.0")}}1.0.11022{{CompatNo}}
+
+ +

関連項目

+ + diff --git a/files/ja/web/api/idbdatabase/createobjectstore/index.html b/files/ja/web/api/idbdatabase/createobjectstore/index.html new file mode 100644 index 0000000000..2063568bb8 --- /dev/null +++ b/files/ja/web/api/idbdatabase/createobjectstore/index.html @@ -0,0 +1,209 @@ +--- +title: IDBDatabase.createObjectStore +slug: Web/API/IDBDatabase/createObjectStore +tags: + - API + - Database + - IDBDatabase + - IndexedDB + - Storage + - createObjectStore +translation_of: Web/API/IDBDatabase/createObjectStore +--- +

{{ APIRef("IDBDatabase") }}

+ +
+

 {{domxref("IDBDatabase")}} インターフェイスのcreateObjectStore() メソッドは、新しいオブジェクトストアやインデックスを生成して返します。

+
+ +

このメソッドは、ストアの名前をとるだけでなく、重要なオプションプロパティを定義するためのオプションオブジェクトもとります。ストアの個々のオブジェクトを一意にするために、プロパティを使用できます。 プロパティが識別子ならば、それはすべてのオブジェクトで一意であり、すべてのオブジェクトはそのプロパティを持つべきです。

+ +

WebKitブラウザでは、オブジェクトストアやインデックスを生成できるようになる前に、{{ domxref("IDBVersionChangeRequest.setVersion")}}メソッドを呼び出さなければなりません。

+ +

構文

+ +
IDBDatabase.createObjectStore(name);
+IDBDatabase.createObjectStore(name, options);
+ +

戻り値

+ +
+
{{domxref("IDBObjectStore")}}
+
新しく生成されたオブジェクトストア。
+
+ +

例外

+ +

このメソッドは、次の型の1つを含む{{domxref("DOMError")}}を伴う{{domxref("DOMException")}}を発生させるかもしれません。

+ + + + + + + + + + + + + + + + + + + + + + +
ExceptionDescription
InvalidStateErrorこのメソッドがversionchangeトランザクションのコールバックとして呼び出されなかった。WebKitブラウザでは、はじめに {{ APIRef("IDBVersionChangeRequest.setVersion")}}を呼び出さなければならない。既に削除されたか取り除かれたオブジェクトを要求した場合も発生する。
ConstraintError与えられた名前のオブジェクトストア(based on case-sensitive comparison) が接続中のデータベースに既に存在する。
InvalidAccessErrorautoIncrementがtrueに設定されていて、keyPathが空文字か空文字を含む配列の場合。
+  
+ +

+ +
 // Let us open our database
+  var request = window.indexedDB.open("toDoList", 4);
+
+  // This event handles the event whereby a new version of the database needs to be created
+  // Either one has not been created before, or a new version number has been submitted via the
+  // window.indexedDB.open line above
+  //it is only implemented in recent browsers
+  request.onupgradeneeded = function(event) {
+    var db = event.target.result;
+
+    db.onerror = function(event) {
+      note.innerHTML += '<li>Error loading database.</li>';
+    };
+
+    // Create an objectStore for this database
+
+    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 });
+
+    objectStore.createIndex("notified", "notified", { unique: false });
+
+    note.innerHTML += '<li>Object store created.</li>';
+  };
+ +

パラメーター

+ +
+
name
+
新しく作られるオブジェクトストア名。
+
optionalParameters
+
+

オプション。メソッドのオプションパラメーターとなる属性を持つオプションオブジェクト。これは次のプロパティを持つ。

+ + + + + + + + + + + + + + + + + + +
AttributeDescription
keyPath新しいオブジェクトストアで使用されるkey path。空や特定されていない場合、オブジェクトストアはKey Pathなしで生成されて、out-of-line keysが使用される。
autoIncrementtrueだった場合、オブジェクトストアはkey generatorを持つ。既定値はfalse。
+ +

未知のパラメーターは無視される。

+
+
+ +

仕様

+ + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IndexedDB', '#widl-IDBDatabase-createObjectStore-IDBObjectStore-DOMString-name-IDBObjectStoreParameters-optionalParameters', 'createObjectStore()')}}{{Spec2('IndexedDB')}}
+ +

ブラウザ実装状況

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support23{{property_prefix("webkit")}}
+ 24
10 {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16.0")}}
10, partial157.1
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support4.4{{CompatGeckoMobile("22.0")}}1.0.11022{{CompatNo}}
+
+ +

関連項目

+ + diff --git a/files/ja/web/api/idbdatabase/index.html b/files/ja/web/api/idbdatabase/index.html new file mode 100644 index 0000000000..784422a490 --- /dev/null +++ b/files/ja/web/api/idbdatabase/index.html @@ -0,0 +1,196 @@ +--- +title: IDBDatabase +slug: Web/API/IDBDatabase +tags: + - API + - Database + - IDBDatabase + - IndexedDB + - Storage + - transactions +translation_of: Web/API/IDBDatabase +--- +

{{APIRef()}}

+
+

IndexedDB APIのIDBDatabaseインターフェイスは、データベースへの接続を提供します。 IDBDatabaseオブジェクトで、データベースのtransactionを開き、データベースのオブジェクト(データ)を生成したり、操作したり、削除したりできます。このインターフェイスはデータベースのバージョンを取得したり、統合したりする唯一の方法を提供します。

+
+
+

Note: Everything you do in IndexedDB always happens in the context of a transaction, representing interactions with data in the database. All objects in IndexedDB — including object stores, indexes, and cursors — are tied to a particular transaction. Thus, you cannot execute commands, access data, or open anything outside of a transaction.

+
+

メソッド

+

Inherits from: EventTarget

+
+
+ {{domxref("IDBDatabase.close")}}
+
+ 即座に応答して、別スレッドでデータベースを閉じる。
+
+ {{domxref("IDBDatabase.createObjectStore")}}
+
+ 新しくオブジェクトストアかインデックスを生成して返す。
+
+ {{domxref("IDBDatabase.deleteObjectStore")}}
+
+ 参照しているインデックスがあったとしても、接続中のデータベースで与えられた名前のオブジェクトストアを削除する。
+
+ {{domxref("IDBDatabase.transaction")}}
+
+ オブジェクトストアにアクセスできる{{domxref("IDBTransaction.objectStore")}}メソッドを含むトランザクションオブジェクト ({{domxref("IDBTransaction")}})を即座に返す。別スレッドで実行される。
+
+

プロパティ

+
+
+ {{domxref("IDBDatabase.name")}} {{readonlyInline}}
+
+ 接続しているデータベース名を含む{{ domxref("DOMString") }} 。
+
+ {{domxref("IDBDatabase.version")}} {{readonlyInline}}
+
+ 接続しているデータベースのバージョンを含む64-bit integer。データベースが初めて作られた場合、この属性は空文字である。
+
+ {{domxref("IDBDatabase.objectStoreNames")}} {{readonlyInline}}
+
+ 接続しているデータベースのobject stores名のリストを含む{{ domxref("DOMStringList") }} 。
+
+

イベントハンドラ

+
+
+ {{domxref("IDBDatabase.onabort")}}
+
+ データベースの接続が中止された場合に発生する。
+
+ {{domxref("IDBDatabase.onerror")}}
+
+ データベースへの接続が失敗した場合に発生する。
+
+ {{domxref("IDBDatabase.onversionchange")}}
+
+

データベースの構造が({{domxref("IDBOpenDBRequest.onupgradeneeded")}}イベントで変更されるか、{{domxref("IDBFactory.deleteDatabase")}} がどこかで(ほとんどの場合、同じコンピューターの他のウィンドウやタブで)要求された場合に発生します。これはversion change transaction (see {{domxref("IDBVersionChangeEvent")}})とは異なりますが、関連があります。

+
+
+

+

次のコードスニペットでは、データベースを非同期で開き({{domxref("IDBFactory")}})、成功と失敗の場合にイベントを登録し、アップグレードが必要な場合には、新しいオブジェクトストアを生成しています({{ domxref("IDBdatabase") }})。 完璧に動作する例は、 To-do Notifications app (view example live.)を見てください。

+
// Let us open our database
+  var DBOpenRequest = window.indexedDB.open("toDoList", 4);
+
+  // these two event handlers act on the IDBDatabase object, when the database is opened successfully, or not
+  DBOpenRequest.onerror = function(event) {
+    note.innerHTML += '<li>Error loading database.</li>';
+  };
+
+  DBOpenRequest.onsuccess = function(event) {
+    note.innerHTML += '<li>Database initialised.</li>';
+
+    // store the result of opening the database in the db variable. This is used a lot later on
+    db = DBOpenRequest.result;
+
+    // Run the displayData() function to populate the task list with all the to-do list data already in the IDB
+    displayData();
+  };
+
+  // This event handles the event whereby a new version of the database needs to be created
+  // Either one has not been created before, or a new version number has been submitted via the
+  // window.indexedDB.open line above
+
+  DBOpenRequest.onupgradeneeded = function(event) {
+    var db = event.target.result;
+
+    db.onerror = function(event) {
+      note.innerHTML += '<li>Error loading database.</li>';
+    };
+
+    // Create an objectStore for this database using IDBDatabase.createObjectStore
+
+    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 });
+
+    objectStore.createIndex("notified", "notified", { unique: false });
+
+    note.innerHTML += '<li>Object store created.</li>';
+  };
+

次の行は、データベースでトランザクションを開いて、そしてオブジェクトストアを開いて、内側のデータを操作しています。

+
    var objectStore = db.transaction('toDoList').objectStore('toDoList'); 
+

仕様

+ + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IndexedDB', '#idl-def-IDBDatabase', 'IDBDatabase')}}{{Spec2('IndexedDB')}} 
+

ブラウザ実装状況

+
+ {{CompatibilityTable}}
+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support23{{property_prefix("webkit")}}
+ 24
10 {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16.0")}}
10, partial157.1
+
+
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support4.4{{CompatGeckoMobile("22.0")}}1.0.11022{{CompatNo}}
+
+

関連情報

+ +

 

diff --git a/files/ja/web/api/idbdatabase/name/index.html b/files/ja/web/api/idbdatabase/name/index.html new file mode 100644 index 0000000000..6be29387f3 --- /dev/null +++ b/files/ja/web/api/idbdatabase/name/index.html @@ -0,0 +1,115 @@ +--- +title: IDBDatabase.name +slug: Web/API/IDBDatabase/name +tags: + - Database + - IDBDatabase + - IndexedDB + - Property + - Storage + - name +translation_of: Web/API/IDBDatabase/name +--- +

{{ APIRef("IDBDatabase") }}

+
+

IDBDatabaseインターフェイスのnameプロパティは、接続しているデータベース名を含む {{ domxref("DOMString")}}です。

+
+

構文

+
db.name
+

+

接続しているデータベース名を含む{{ domxref("DOMString")}}。

+

+

この例は接続しているデータベースと、DBのversionとnameプロパティを持つ{{domxref("IDBDatabase")}} オブジェクトの結果、そしてログを表示します。完全な例は、To-do Notifications app (view example live)を見てください。

+
// Let us open 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 += '<li>Error loading database.</li>';
+};
+
+DBOpenRequest.onsuccess = function(event) {
+  note.innerHTML += '<li>Database initialised.</li>';
+
+  // store the result of opening the database in the db variable. This is used a lot below
+  db = DBOpenRequest.result;
+
+  // This line will log the name of the database, which should be "toDoList"
+  console.log(db.name);
+};
+

仕様

+ + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IndexedDB', '#widl-IDBDatabase-name', 'name')}}{{Spec2('IndexedDB')}} 
+

ブラウザ実装状況

+
+ {{CompatibilityTable}}
+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support23{{property_prefix("webkit")}}
+ 24
10 {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16.0")}}
10, partial157.1
+
+
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support4.4{{CompatGeckoMobile("22.0")}}1.0.11022{{CompatNo}}
+
+

関連情報

+ diff --git a/files/ja/web/api/idbdatabase/objectstorenames/index.html b/files/ja/web/api/idbdatabase/objectstorenames/index.html new file mode 100644 index 0000000000..78cff593a8 --- /dev/null +++ b/files/ja/web/api/idbdatabase/objectstorenames/index.html @@ -0,0 +1,115 @@ +--- +title: IDBDatabase.objectStoreNames +slug: Web/API/IDBDatabase/objectStoreNames +tags: + - Database + - IDBDatabase + - IndexedDB + - Property + - Storage + - objectStoreNames +translation_of: Web/API/IDBDatabase/objectStoreNames +--- +

{{ APIRef("IDBDatabase") }}

+
+

{{domxref("IDBDatabase")}}インターフェイスのobjectStoreNamesプロパティは、現在接続しているデータベースのobject stores名のリストを含む{{ domxref("DOMStringList") }}です。

+
+

構文

+
db.objectStoreNames
+

+

現在接続しているデータベースのobject stores名のリストを含む{{ domxref("DOMStringList") }}。

+

+
// Let us open 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 += '<li>Error loading database.</li>';
+};
+
+DBOpenRequest.onsuccess = function(event) {
+  note.innerHTML += '<li>Database initialised.</li>';
+
+  // store the result of opening the database in the db variable. This is used a lot below
+  db = DBOpenRequest.result;
+
+  // This line will log the version of the connected database, which should be
+  // an object that looks like { ['my-store-name'] }
+  console.log(db.objectStoreNames);
+};
+

仕様

+ + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IndexedDB', '#widl-IDBDatabase-objectStoreNames', 'objectStoreNames')}}{{Spec2('IndexedDB')}} 
+

ブラウザ実装状況

+
+ {{CompatibilityTable}}
+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support23{{property_prefix("webkit")}}
+ 24
10 {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16.0")}}
10, partial157.1
+
+
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support4.4{{CompatGeckoMobile("22.0")}}1.0.11022{{CompatNo}}
+
+

関連情報

+ diff --git a/files/ja/web/api/idbdatabase/version/index.html b/files/ja/web/api/idbdatabase/version/index.html new file mode 100644 index 0000000000..05d3e26e56 --- /dev/null +++ b/files/ja/web/api/idbdatabase/version/index.html @@ -0,0 +1,114 @@ +--- +title: IDBDatabase.version +slug: Web/API/IDBDatabase/version +tags: + - Database + - IDBDatabase + - IndexedDB + - Property + - Storage + - version +translation_of: Web/API/IDBDatabase/version +--- +

{{ APIRef("IDBDatabase") }}

+
+

{{domxref("IDBDatabase")}}インターフェイスのversionプロパティ は、接続しているデータベースのバージョンを含む64-bit integerです。データベースを初めて生成した時、この属性は空文字です。

+
+

構文

+
db.version
+

+

接続しているデータベースのバージョンを含む整数値。

+

+
// Let us open 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 += '<li>Error loading database.</li>';
+};
+
+DBOpenRequest.onsuccess = function(event) {
+  note.innerHTML += '<li>Database initialised.</li>';
+
+  // store the result of opening the database in the db variable. This is used a lot below
+  db = DBOpenRequest.result;
+
+  // This line will log the version of the connected database, which should be "4"
+  console.log(db.version);
+};
+

仕様

+ + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('IndexedDB', '#widl-IDBDatabase-version', 'version')}}{{Spec2('IndexedDB')}} 
+

ブラウザ実装状況

+
+ {{CompatibilityTable}}
+
+ + + + + + + + + + + + + + + + + + + +
FeatureChromeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support23{{property_prefix("webkit")}}
+ 24
10 {{property_prefix("moz")}}
+ {{CompatGeckoDesktop("16.0")}}
10, partial157.1
+
+
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidFirefox Mobile (Gecko)Firefox OSIE PhoneOpera MobileSafari Mobile
Basic support4.4{{CompatGeckoMobile("22.0")}}1.0.11022{{CompatNo}}
+
+

関連情報

+ -- cgit v1.2.3-54-g00ecf