成功.delete()我想知道是否有人已經想通了如何「正確」檢查,如果在索引資料的delete()
功能確實成功刪除的記錄。檢查在IndexedDB的
我發現這一點:
// As per spec http://www.w3.org/TR/IndexedDB/#object-store-deletion-operation
// the result of the Object Store Deletion Operation algorithm is
// undefined, so it's not possible to know if some records were actually
// deleted by looking at the request result.
這是否只是一種節約刪除,刪除記錄,然後檢查是否記錄在數據庫之前記錄鍵的事?
糾正我,如果我錯了,但沒有上面的報價意味着,不管'onsuccess'觸發'delete'可能沒有成功? – user1460015
IndexedDB使用[原子事務](https://en.wikipedia.org/wiki/Atomic_transaction)。 'onsuccess'因爲刪除**成功**而觸發,如果在同一個事務上的另一個操作失敗,它可能會在成功後返回__。如果您對交易進行多項操作,則這一點至關重要;如果僅爲刪除創建事務,並且不對事務執行其他任何操作,則在刪除成功時,事務不會有任何失敗的機會。 –
這是否也適用於'add()'方法?因爲它也被提到,即使'onsuccess'被觸發並不一定意味着它是「成功的」。 – user1460015