--- 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);
};
| Specification | Status | Comment |
|---|---|---|
| {{SpecName('IndexedDB', '#widl-IDBDatabase-version', 'version')}} | {{Spec2('IndexedDB')}} |
{{Compat("api.IDBDatabase.version")}}