Refactor database connection system

The old `getDb()` way of doing things isn't working out. This is especially ugly:

```js
return getDb.call(this).then(function(db) {
    // do stuff with db
}
```

This patch deals with the scope of `this` better, and also adds a function `getStore` for quick, DRY retrieval of the main store object in the CRUD methods.