-
-
Notifications
You must be signed in to change notification settings - Fork 652
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed so that delete() will never divide chunks in separate transac…
…tions. I thought it over. It's complicated to explain the purpose of chunking when there are two different purposes. And it would behave differently on different browsers and it would diverse from other db operations that all are atomic even when called from outside a transaction. Also, if being afraid of starved transaction, the use case can be accomplished in a better way than relying on WriteableCollection.delete() to give the breath to transactions. Instead, the user could do something like: ```js var collection = db.table.where('shouldBeDelete').equals("true"); var numDeleted; do { numDeleted = yield db.transaction('rw!', db.table, function*() { var timeout = Date.now() + 1000; return yield collection .clone({table: db.table}) // Bind collection to current transaction. .until(()=>Date.now() > timeout, true) // true means will always execute once at least. .delete(); }); } while (numDeleted > 0); ```
- Loading branch information
1 parent
9ad2018
commit d539d18
Showing
2 changed files
with
49 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters