【发布时间】:2013-08-09 13:27:45
【问题描述】:
我有一个使用 JavaScript 和 IndexedDB 的 Web 应用程序, 我用它来存储一个blob / uint(在Chrome中),带有索引键(唯一), 我只需实现即可轻松更新 blob:
var blob1=this.request.result; //the blob file(e.g. image)
var blob2=null;
var FileStorage = [
{ id: "10012", filedata:blob1 },
{ id: "10013", filedata:blob2 }
];
var objectStore = transaction.objectStore("storage");
for (var i in FileStorage) {
var request = objectStore.put(FileStorage[1]);
request.onsuccess = function(event) {
console.log("success");
};
}
我实现了 .put(),而不是 .add() 来更新记录,在这种情况下,我更新了 id 为 10013 的文件数据,
但是现在,我面临重命名现有记录的 id 的问题,例如,我想将第一条记录(id 10012)更改为 id:10019 而不更改/修改文件数据,但我有很难找到方法。同样,id 是唯一的
【问题讨论】:
标签: javascript indexeddb