问题
I am just starting to use indexeddb and transforming Web SQL.
I tried to use add and put to add some data in data store. I could not really see what is/are the difference/s of using these two functions.
I think I have to know the difference so I could use them appropriately.
Thanks forward
回答1:
The difference between add and put is same as in any API.
If you try to insert an element with key that already exist using the put
function it will trigger and update of the existing element, however if you use the add
function and element with same id exist you will get an error with the following message: "Key already exists in the object store."
来源:https://stackoverflow.com/questions/27357391/what-is-the-difference-between-add-and-put-in-indexeddb