倉庫指標
- Star
- (8,900 star)
- PR 合併指標
- (平均合併 7天 3小時) (30 天內合併 147 個 PR)
描述
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
- Folder:
en-us/web/api/idbdatabase - MDN URL: https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase
- GitHub URL: https://github.com/mdn/content/blob/main/files/en-us/web/api/idbdatabase/index.md
- Last commit: https://github.com/mdn/content/commit/89c582f832c8700f7bccef50dabea59350fe3906
- Document last modified: 2023-03-21T06:14:00.000Z