IndexedDB is one of the storage capabilities introduced into browsers over the years. It’s a key/value store (a noSQL database) considered to be the definitive solution for storing data in browsers.
It’s an asynchronous API, which means that performing costly operations won’t block the UI thread providing a sloppy experience to users. It can store an indefinite amount of data, although once over a certain threshold the user is prompted to give the site higher limits.
It supports transactions, versioning and gives good performance. And compared to local storage, we can store much more data into it.
While you can technically create multiple databases per site, you generally create one single database, and inside that database you can create multiple object stores.
A database is private to a domain, so any other site cannot access another website IndexedDB stores.
Each store usually contains a set of things, which can be
For example you might have a store that contains posts, another that contains comments.
A store contains a number of items which have a unique key, which represents the way by which an object can be identified.
You can alter those stores using transactions, by performing add, edit and delete operations, and iterating over the items they contain.
Lessons in this unit:
|Loading the idb library
|Creating a database and a store
|Adding data into a store
|Retriving data from a store