Sunday, 29 July 2018

IndexedDB simple wrapper with examples

Indexed dB
○ Use as data storage at client end(web browser) support data access in same domain.
○ As we  already have 2 popular storage like  sessionStorage, localStorage, but its more powerful when its comes to size and Api.
○ We can also say it is alternative of deprecated local storage Web SQL database.
○ It is not a relational database, its NoSQL, storage based on Key, Pair values so we can say  its not a structured query language.
○ We can store structured data, including files/blobs.
○ Data can be indexed according to search keys, so provide faster search.
○ Support almost all major browsers: Chrome, Firefox, IE11, UC

Important terms
○ Database - Top level objects, that treat as DB, we can have multiple DB with different name based on requirements.
○ Object store - Treat as collection of  structured data object, like table but not table.
○ Index - Mechanism to organise objects store so that sorting, fetching would be efficient.
○ Operation - An interaction with the database.
○ Transaction -  it provide atomic read-modify-write operations as thread safe.
○ Cursor - Iteration over object with in Object Store.

○ indexedDB
○ Open
○ createObjectStore
○ Put()
○ Delete(), Clear()
○ getAll(), Get()

○ localForage
○ Dexie.js
○ ZangoDB
○ JsStore
○ MiniMongo
○ PouchDB
○ Jquery

I have created my own, example available on
Based on your requirement you can modified it easily.