pouchdb-hoodie-api icon indicating copy to clipboard operation
pouchdb-hoodie-api copied to clipboard

api.add after api.clear does not resolve or reject

Open gr2m opened this issue 9 years ago • 0 comments

var PouchDB = require('pouchdb').defaults({db: require('memdown')})
PouchDB.plugin(require('.'))

var db = new PouchDB('foo')
var api = db.hoodieApi()
api.clear()

.then(function () {
  console.log('cleared')
  return api.add({})  
})

.then(console.log)

.catch(console.log)

This code logs 'cleared', but the promise from api.add({}) remains pending.

Note that once db.destroy() is called, the db instance cannot be used anymore. We have to unbind all event handlers and replace state.db with a new instance (here)

gr2m avatar Dec 27 '15 12:12 gr2m