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
Before creating the database I want to tell you about the two API modes of IndexedDB. Synchronous mode: This mode was created to be used only in conjunction with web workers. But most browsers currently do not support the synchronous mode.
The keyPath read-only property of the IDBObjectStore interface returns the key path of this object store. If this property is null, the application must provide a key for each modification operation.
The W3C has announced that the Web SQL database is a deprecated local storage specification so web developer should not use this technology any more. indexeddb is an alternative for web SQL data base and more effective than older technologies.
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."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With