Closed Bug 1358701 Opened 7 years ago Closed 5 years ago

IDBObjectStore.put should mention that you have to supply the primary key in the second argument if you want to modify a record and your object store uses an autoIncrement key

Categories

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

All
Other
enhancement

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mstange, Assigned: cmills)

References

()

Details

:: Developer Documentation Request

      Request Type: Correction
     Gecko Version: unspecified
 Technical Contact: 

:: Details

For object stores that have an autoIncrement primary key, the key is not in a field on the record object. So calling put(record) will always insert a new record, because it doesn't know what existing record you might want to modify. So you if you really want to modify an existing record, you'll need to call put(record, cursor.primaryKey) (or get the primaryKey from somewhere else).

The documentation should spell this out.
Component: General → API: IndexedDB
Gah, this page is badly written ;-)

To improve things, I've updated the summary (first paragraph of the page) to say more clearly what the method actually does, and added a parameters section that explains what you cited as missing in this bug:

https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/put#Parameters

Let me know if you think this is better now.
Assignee: nobody → cmills
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.