Closed
Bug 1374973
Opened 7 years ago
Closed 4 years ago
Shouldn't success only be reported from the transaction and not from the request?
Categories
(Developer Documentation Graveyard :: API: IndexedDB, enhancement, P5)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: hasenstein, Assigned: cmills)
References
()
Details
:: Developer Documentation Request
Request Type: Correction
Gecko Version: unspecified
Technical Contact:
:: Details
As I understand IndexedDB, and I read a bit in the spec document too, success of an operation should not be assumed from the request but from the transaction.
All the examples on MDN use the request.onsuccess handler to report success of operations such as adding or deleting entries from the DB.
To be maximally confusing, the examples on pages such as https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/add actually do BOTH:
- in request.onsuccess they report "New item added to database.';
- in transaction.oncomplete they report Transaction completed: database modification finished.
Which is it? How can the "item added to the database" be true if the transaction still is pending?
Are request results - successes that is - not completely useless, only errors mean something?
Should not ALL successes be reported from the respective transaction?
Reporter | ||
Comment 1•7 years ago
|
||
Related: questions such as this on SO https://stackoverflow.com/questions/11149388/indexeddb-differences-between-onsuccess-and-oncomplete
For the example code:
I think what would be okay is NOT actually modifying the DOM right "onsuccess" (request), but to collect all successes (add to a string with HTML), and only update the DOM after the transaction completes successfully.
Right now the examples are misleading or confusing, leading to questions about the difference between request.onsuccess and transaction.oncomplete for those people who take the time to think, and the assumption that it does not matter or that they should use request.onsuccess by those programmers who are in a hurry to just get the code to produce a result without error.
Assignee | ||
Comment 2•7 years ago
|
||
I can totally see your point here. I wrote these examples a very long time ago when I was inexperienced with IDB, and didn't understand the difference. I am sad that this stuff has been misleading for so long!
I have gone through all the IDB docs and changed any instances I've found of misleading messages around onsuccess/oncomplete. I've also updated the accompanying to-do-list demo.
Let me know if you spot anything else that could do with improvement. Thanks.
Assignee: nobody → cmills
Comment 3•4 years ago
|
||
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: UNCONFIRMED → RESOLVED
Closed: 4 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•