Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

indexeddb

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 */}
like image 440
enguerran Avatar asked Nov 21 '12 12:11

enguerran


1 Answers

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

like image 115
Kristof Degrave Avatar answered Sep 23 '22 06:09

Kristof Degrave