IDBDatabase: close() method
The close()
method of the IDBDatabase
interface returns immediately and closes the connection in a separate thread.
The connection is not actually closed until all transactions created using this connection are complete. No new transactions can be created for this connection once this method is called. Methods that create transactions throw an exception if a closing operation is pending.
Syntax
Parameters
Return value
Examples
const DBOpenRequest = window.indexedDB.open("toDoList", 4);
DBOpenRequest.onerror = (event) => {
note.innerHTML += "<li>Error loading database.</li>";
};
DBOpenRequest.onsuccess = (event) => {
note.innerHTML += "<li>Database initialized.</li>";
db = DBOpenRequest.result;
db.close();
};
Specifications
Browser compatibility
|
Desktop |
Mobile |
|
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
WebView Android |
Chrome Android |
Firefox for Android |
Opera Android |
Safari on IOS |
Samsung Internet |
close |
23 |
12 |
10 |
10 |
15 |
8 |
4.4 |
25 |
22 |
14 |
8 |
1.5 |
See also