mdn/content

leading the developer down a dead end in onupgradeneeded

Open

#26,638 opened on May 8, 2023

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Markdown (22,427 forks)batch import
Content:WebAPIarea: IndexedDBhelp wanted

Repository metrics

Stars
 (8,900 stars)
PR merge metrics
 (Avg merge 7d 3h) (147 merged PRs in 30d)

Description

MDN URL

https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase

What specific section or headline is this issue about?

Example code

What information was incorrect, unhelpful, or incomplete?

The example code that is provided leads the developer to a dead end. The onupgradeneeded gets called when initializing from no database but when the next version comes you will get an error when you get to the line that calls db.createObjectStore because the database has already been created. The example code is using bad form.

What did you expect to see?

I expect to see code that is actually usable IRL and not just in some one-shot example that is stuck on the initial version and can't upgrade in the future. (the example uses version "4" which is impossible to iterate incrementally to version 4 from version 1 using this code). Even the "complete working example" that the documentation mentions does this same mistake that can't ever upgrade past the initial version.

Do you have any supporting links, references, or citations?

Here is someone that is as lost as I am asking the same question 3 years ago. Only one answer from Josh and I don't even think the answer is correct and it also lacks useful details as Robert Wilding comments. Robert did research and also brings up that "a good walkthrough on how to build and keep a proper migration path seems to be missing." I agree with Robert.

Do you have anything more you want to share?

No response

MDN metadata

Contributor guide