function openDatabase(dbName) {
var request = indexedDB.open(dbName);
request.onsuccess = function (e) {
var database = request.result;
if (database) {
console.log("Database initialized.");
} else {
console.error("Database is not initialized!");
}
//Your code goes here
database.close();
}
request.onerror = function (e) {
console.error( e.target.error.message);
}
}