Opening an indexedDB database

The indexedDB object is available on the window object. You will need to actually open a database in order to store data in indexedDB, shown as follows:

const open = window.indexedDB.open("myDB", 1);

You have to first request to open the database from indexedDB. The first parameter here is the name of your database. If it doesn't exist, it'll be created automatically.

The second parameter is the version number of the database. What that means is that you can assign a version number to every database schema, which is useful in the following example.

Consider that you shipped your application that is using indexedDB. Now, indexedDB consists of a database schema, which lays down certain rules on how the data should ...

Get Learn ECMAScript - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.