/
index.md
45 lines (32 loc) · 1.4 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
---
title: indexedDB
slug: Web/API/Window/indexedDB
original_slug: Web/API/indexedDB
---
{{ APIRef() }}
グローバルの **`indexedDB`** は読み取り専用プロパティで、アプリケーションが indexed データベースの機能に非同期でアクセスするための機構を提供します。
### 値
{{domxref("IDBFactory")}} オブジェクトです。
## 例
以下のコードでは、データベースを開くためのリクエストを非同期に作成し、データベースが開かれた後で、リクエストの `onsuccess` ハンドラーが呼び出されます。
```js
let db;
function openDB() {
const DBOpenRequest = window.indexedDB.open("toDoList");
DBOpenRequest.onsuccess = (e) => {
db = DBOpenRequest.result;
};
}
```
## 仕様書
{{Specifications}}
## ブラウザーの互換性
{{Compat}}
## 関連情報
- [IndexedDB の使用](/ja/docs/Web/API/IndexedDB_API/Using_IndexedDB)
- トランザクションの開始: {{domxref("IDBDatabase")}}
- トランザクションの使用: {{domxref("IDBTransaction")}}
- キーの範囲設定: {{domxref("IDBKeyRange")}}
- データの取得と変更: {{domxref("IDBObjectStore")}}
- カーソルの使用: {{domxref("IDBCursor")}}
- 参照例: [To-do Notifications](https://github.com/mdn/dom-examples/tree/main/to-do-notifications)([例をライブで参照](https://mdn.github.io/dom-examples/to-do-notifications/))