Getting the id of an object added to an indexedDB object store

indexeddb

Solution

You can find the inserted key in e.target.result.

Problem

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 */} ```

Original source