Closed Bug 1358700 Opened 7 years ago Closed 4 years ago

IDBDatabase.deleteObjectStore() should have a more reasonable example and describe how to handle upgrades vs first setup

Categories

(Developer Documentation Graveyard :: API: IndexedDB, enhancement, P5)

All
Other
enhancement

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: mstange, Unassigned)

References

()

Details

:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: unspecified
 Technical Contact: 

:: Details

Usually, the reason you want to delete an object store is that a previous version of your database schema had an object store that you don't need anymore. However, your upgradeneeded handler runs both in the case of an upgrade from that previous version, and in case of a new database setup, or even in case of an upgrade from a much older version which might not have had the object store that you want to delete. Calling deleteObjectStore indiscriminately will throw an exception in all the cases where there was no such object store already.

The page should call attention to that fact and suggest ways to get around it.

One solution seems to be to look at versionChangeEvent.oldVersion, and only call deleteObjectStore if oldVersion is one of the versions that you know had the object store in question.
Oh, and the example should be something that you'd actually want to write. Creating an object store just to throw it away afterwards is not all that useful.
Component: General → API: IndexedDB
Yup, that was a really crappy example! I've updated it with something simpler that is more plausible and makes it more obvious. Does that work for you?
MDN Web Docs' bug reporting has now moved to GitHub. From now on, please file content bugs at https://github.com/mdn/sprints/issues/ and platform bugs at https://github.com/mdn/kuma/issues/.
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.