Mailspring/spec
Ben Gotow ea76b7c442 feat(transactions): Explicit (and faster) database transactions
Summary:
Until now, we've been hiding transactions beneath the surface. When you call persistModel, you're implicitly creating a transaction.
You could explicitly create them with `atomically`..., but there were several critical problems that are fixed in this diff:

- Calling persistModel / unpersistModel within a transaction could cause the DatabaseStore to trigger. This could result in other parts of the app making queries /during/
  the transaction, potentially before the COMMIT occurred and saved the changes. The new, explicit inTransaction syntax holds all changes until after COMMIT and then triggers.

- Calling atomically and then calling persistModel inside that resulted in us having to check whether a transaction was present and was gross.

- Many parts of the code ran extensive logic inside a promise chained within `atomically`:

  BAD:

```
  DatabaseStore.atomically =>
   DatabaseStore.persistModel(draft) =>
     GoMakeANetworkRequestThatReturnsAPromise
```

OVERWHELMINGLY BETTER:

```
  DatabaseStore.inTransaction (t) =>
     t.persistModel(draft)
  .then =>
    GoMakeANetworkRequestThatReturnsAPromise
```

Having explicit transactions also puts us on equal footing with Sequelize and other ORMs. Note that you /have/ to call DatabaseStore.inTransaction (t) =>. There is no other way to access the methods that let you alter the database. :-)

Other changes:
- This diff removes Message.labels and the Message-Labels table. We weren't using Message-level labels anywhere, and the table could grow very large.
- This diff changes the page size during initial sync from 250 => 200 in an effort to make transactions a bit faster.

Test Plan: Run tests!

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D2353
2015-12-17 11:46:05 -08:00
..
components fix(editable-list): Prevent empty selection on esc pressed + other fixes 2015-12-14 14:29:45 -08:00
fixtures feat(paste): Paste accepts more HTML, paste and match style now available 2015-12-07 15:34:03 -08:00
models feat(observables): Implementation of observables to replace some stores 2015-12-07 16:52:46 -08:00
services feat(paste): Paste accepts more HTML, paste and match style now available 2015-12-07 15:34:03 -08:00
stores feat(transactions): Explicit (and faster) database transactions 2015-12-17 11:46:05 -08:00
tasks feat(transactions): Explicit (and faster) database transactions 2015-12-17 11:46:05 -08:00
action-bridge-spec.coffee
auto-update-manager-spec.coffee
buffered-process-spec.coffee
clipboard-spec.coffee
component-registry-spec.coffee
database-object-registry-spec.coffee
database-view-spec.coffee
dom-utils-spec.coffee
extension-registry-spec.coffee
jasmine-helper.coffee refactor(spec): remove spectron from main app 2015-12-02 13:42:09 -08:00
jasmine-jquery.js
jasmine.js
launch-services-spec.coffee
menu-manager-spec.coffee
model-view-selection-spec.coffee
model-view-spec.coffee
module-cache-spec.coffee
n1-spec-reporter.coffee fix(*): Fix for "apply is not a function" lost in revert of e275f35 2015-12-10 14:12:16 -08:00
nylas-api-spec.coffee feat(transactions): Explicit (and faster) database transactions 2015-12-17 11:46:05 -08:00
nylas-env-spec.coffee
nylas-protocol-handler-spec.coffee
nylas-test-utils.coffee
package-manager-spec.coffee
package-spec.coffee
quoted-html-transformer-spec.coffee feat(paste): Paste accepts more HTML, paste and match style now available 2015-12-07 15:34:03 -08:00
quoted-plain-text-transformer-spec.coffee feat(paste): Paste accepts more HTML, paste and match style now available 2015-12-07 15:34:03 -08:00
spec-bootstrap.coffee feat(spec): add config dir to integration specs 2015-12-10 10:52:20 -05:00
spec-helper-platform.coffee
spec-helper.coffee feat(transactions): Explicit (and faster) database transactions 2015-12-17 11:46:05 -08:00
spec-suite.coffee
spellchecker-spec.coffee fix(spellcheck): let win < 8 fallback to hunspell 2015-12-11 16:41:41 -05:00
style-manager-spec.coffee
styles-element-spec.coffee
theme-manager-spec.coffee
time-override.coffee
time-reporter.coffee
undo-manager-spec.coffee
utils-spec.coffee fix(serialization): Inflate / deflate JSON from database with registered object system 2015-12-08 15:14:43 -08:00