Open In App

HTML DOM indexedDB databases() Method

Last Updated : 19 Jul, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The databases() method of the indexedDB interface returns a list representing all the available databases in the document, with their names and versions.

Syntax:

dbs = indexedDB.databases();

Parameters: The method does not take any parameters.
Return value: This method returns a promise containing a list of dictionaries, each with two elements, name and version.
Example: In this example, we will open a database and hence, will get the databases using this method.




<!DOCTYPE HTML> 
<html>  
<head>
    <title>indexedDB databases() method</title>
</head>   
<body style="text-align:center;">
    <h1 style="color:green;">  
        GeeksforGeeks  
    </h1
    <p
    HTML | indexedDB databases() method
    </p>
    <button onclick = "Geeks()">
    Click Here
    </button>   
    <script
        function Geeks(){
         var request = 
           window.indexedDB.open("newDatabase", 1);
         console.log(window.indexedDB.databases())
     }
  </script
</body>   
</html>


Output:

Before Button Click:

After Button Click: In the console, the promise can be seen.

Supported Browsers:

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera

Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads