Given a indexeddb database with one declared objectstore as:
var objectStore = thisDb.createObjectStore("table", {keyPath: "id", autoIncrement: true})
When I add an new item with the add request:
var resp = objectStore.add(row)
How can I get the new id of this added item in the onsuccess function?
resp.onsuccess = function(e) { /* code to get the id of the added item */}
You can find the inserted key in e.target.result.
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