我正在使用put()将一个值保存到Dexie(IndexedDB)数据库中,并且我立即需要知道这个新条目的键是什么。
下面是我的代码。我无法找到一个解决方案搜索与谷歌。谢谢!
let newDog = {
armbandNumber: this.armbandMax,
dogCallName: this.callName,
dogRegName: this.regName,
dogOwnerKey: this.dogOwner.value,
dogOwner: this.dogOwner.label,
dogCoOwner: this.dogCoOwner,
dogHandler: this.dogHandler.value,
dogBday: this.dogBday,
dogBreed: this.dogBreed,
dogHeight: this.dogHeight,
dogVariety: this.dogVariety,
dogSire: this.dogSire,
dogDam: this.dogDam,
dogBreeder: this.dogBreeder,
akcNum: this.akcNum,
bhaNum: this.bhaNum,
dogGender: this.dogGenderModel,
dateDogAdded: Date.now(),
barnHuntLevel: this.bhLevelModel,
barnHuntClassAB: this.bhLevelModelAB,
dogHeightDivision: this.heightDivision,
scentWorkLevel: this.swLevelModel,
scentWorkClassAB: this.swLevelModelAB,
}
pawTapDB.dogTable.put(newDog)
1条答案
按热度按时间mfuanj7w1#
https://dexie.org/docs/Table/Table.put()表示:
如果操作成功,则返回的Promise解析为表中存储对象时所用的键。
所以这样做: