使用 objectstore.put() 将记录插入 IndexedDB 后,如何返回自动递增的 ID?
下面是我的代码:
idb.indexedDB.addData = function (objectStore, data) {
var db = idb.indexedDB.db;
var trans = db.transaction([objectStore], READ_WRITE);
var store = trans.objectStore(objectStore);
var request = store.put(data);
request.onsuccess = function (e) {
//Success, how do I get the auto incremented id?
};
request.onerror = function (e) {
console.log("Error Adding: ", e);
};
};