Mailspring/spec-nylas/stores
Evan Morikawa cd9ccd85e2 refactor(DB): promisify database
Summary:
WIP. The app launches and works for me. I still need to fix the tests
just the DB ones though :D

I changed the `DatabaseProxy` into a `DatabaseConnection` object. It will
request a fully instantiated databse from the backend Browser.

If we're already setup, it'll connect straight to the existing DB.

If we're not setup, then it'll create a new database and run the inital
schema migration on it. The `_createNewDatabase` promise won't resolve
until the migration has run.

Until we add in a more sophisticated migration system and get rid of the
stupid `modelClassMap` that's shoved in `Utils`, I'm passing in a series
of `_setupQueries()` to get everything started.

The `DatabaseConnection` is also the one responsible for queuing up
queries until the DB is fully populated and ready to go.

We actually get a lot of queries before we're setup because a lot of
Stores will make DB requests on `require` in their `constructor` or `init`
methods. (remember all the times we call `_populateStore` in `init`).

Now those queries are aggregated by the `DatabaseConnection` and then
executed sequentially.

Our methods like `persistModel` now resolve only after both the queries
have completed AND their corresponding `triggerLater` has completed as
well.

Test Plan: in progress

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1688
2015-06-26 07:42:41 -07:00
..
contact-store-spec.coffee refactor(utils): switch to regular underscore 2015-05-19 16:06:59 -07:00
database-connection-spec.coffee refactor(DB): promisify database 2015-06-26 07:42:41 -07:00
database-store-spec.coffee refactor(DB): promisify database 2015-06-26 07:42:41 -07:00
draft-store-spec.coffee fix(mailto): Use paste logic to parse fields in mailto links, support poorly encoded URLs 2015-06-18 11:58:07 -07:00
file-upload-store-spec.coffee refactor(DB): promisify database 2015-06-26 07:42:41 -07:00
focused-contacts-store-spec.coffee fix(naming): Move atom/inbox/nilas refs to Nylas 2015-05-15 11:07:28 -07:00
focused-content-store-spec.coffee fix(mark-as-read): Wait for messages to load, then 700msec, before marking as read 2015-06-17 19:58:20 -07:00
focused-tag-store-spec.coffee refactor(utils): switch to regular underscore 2015-05-19 16:06:59 -07:00
message-store-spec.coffee fix(mark-as-read): Wait for messages to load, then 700msec, before marking as read 2015-06-17 19:58:20 -07:00
metadata-store-spec.coffee fix(naming): Move atom/inbox/nilas refs to Nylas 2015-05-15 11:07:28 -07:00
namespace-store-spec.coffee fix(mailto): Handle mailto on application launch, populate NamespaceStore synchronously 2015-05-21 18:08:29 -07:00
task-queue-spec.coffee fix(asar): Support ASAR, and running of specs in prod builds 2015-05-21 14:41:30 -07:00