给定一个 indexeddb 数据库,其中一个声明的对象存储为:
var objectStore = thisDb.createObjectStore("table", {keyPath: "id", autoIncrement: true})
当我使用添加请求添加新项目时:
var resp = objectStore.add(row)
如何在 onsuccess 函数中获取此添加项的新 id?
resp.onsuccess = function(e) { /* code to get the id of the added item */}
您可以在 e.target.result 中找到插入的密钥。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)