Reconfigured for PouchDB, works with promises