-
-
Notifications
You must be signed in to change notification settings - Fork 641
WriteableCollection.delete()
Deletes all objects in the query.
collection.delete()
Promise where result is the Number of deleted records.
If any object fails to be deleted or an exception occur in a callback function, entire operation will fail and transaction will be aborted.
If you catch the returned Promise, transaction will not abort, and you recieve a Dexie.MultiModifyError error object containing the following properties:
failures | Array of Error objects of all errors that have occurred |
failedKeys | Array of the keys of the failed modifications. This array will have the same order as failures so that failures[i] will always represent the failure of failedKeys[i] |
successCount | Number of successful deletions made. |
If you do NOT catch the returned Promise, and an error occur, the transaction will be aborted.
If you want to log the error but still abort the transaction, you must encapsulate the operation in a transaction() block and catch the transaction instead. It is also possible to catch the operation and call transaction.abort() in the catch() clause.
db.orders.where("state").anyOf("finished", "discarded").or("date").below("2014-02-01").delete()
.then(function (deleteCount) {
console.log( "Deleted " + deleteCount + " objects"):
});
WriteableCollection.delete() is equivalent to:
WriteableCollection.modify(function () {delete this.value;});
Dexie.js - minimalistic and bullet proof indexedDB library