hoodiehq / pouchdb-hoodie-api

:dog: Hoodie-like API for PouchDB
https://hoodiehq.github.io/pouchdb-hoodie-api
Apache License 2.0
44 stars 11 forks source link

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

Open gr2m opened 8 years ago

gr2m commented 8 years ago
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)