for (i in peopleData) {
objectStore.add(peopleData[i]);
}
};
}
4. [代码]事务处理
//判断是否支持事务处理
var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction;
var transaction = db.transaction("people", IDBTransaction.READ_WRITE);
var objectStore = transaction.objectStore("people");
var request = objectStore.add({ name: name, email: email });
request.onsuccess = function (evt) {
// do something when the add succeeded
};
transaction.oncomplete = function(evt) {
// do something after the transaction completed
};
5. [代码]完整例子