files/en-us/web/api/workerglobalscope/indexeddb/index.md
{{APIRef("IndexedDB")}}{{AvailableInWorkers("worker")}}
The indexedDB read-only property of the {{domxref("WorkerGlobalScope")}} interface provides a mechanism for workers to
asynchronously access the capabilities of indexed databases.
An {{domxref("IDBFactory")}} object.
The following code creates a request for a database to be opened asynchronously, after
which the database is opened when the request's onsuccess handler is fired:
let db;
function openDB() {
const DBOpenRequest = self.indexedDB.open("toDoList");
DBOpenRequest.onsuccess = (e) => {
db = DBOpenRequest.result;
};
}
{{Specifications}}
{{Compat}}