DEV Community

Discussion on: Make websites work offline - Offline Storage. Making IndexedDB the Hero!

Collapse
 
raymondcamden profile image
Raymond Camden

"When you create a new database, the onupgradeneeded event will be triggered."
It will be fired when you create a new database, and when you change the version number of the database. Your example doesn't show that in the open call, but you can specify a version number and increment it to make schema changes.

Collapse
 
saurabhdaware profile image
Saurabh Daware 🌻

Yes it does fire when version is changed, I am not really sure what is exactly the usecase of the versions in IndexedDB?

I never really had to work on the versions and I wanted to keep the article "Getting started" rather than "Know everything" so I skipped the versioning to keep it simple and so that people can compare it with other database they've worked on.

Collapse
 
raymondcamden profile image
Raymond Camden

You use versions to handle the case where you need to change the objectstore. Like maybe your business needs changed, etc. When I teach IDB, I stress that you should try your best to "get it right the first time" so you don't have to handle versioning changes.