Skip to content

Commit

Permalink
fix: handle destroy w/o setup
Browse files Browse the repository at this point in the history
  • Loading branch information
garbados committed Mar 11, 2021
1 parent fdb73fd commit c0c68be
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,15 @@ module.exports = function (PouchDB) {
}
// destroy wrapper that destroys both the encrypted and decrypted DBs
PouchDB.prototype.destroy = function (opts = {}, callback) {
const promise = destroy.call(this._encrypted, opts).then(() => {
return destroy.call(this, opts)
})
let promise
if (!this._encrypted) {
promise = destroy.call(this)
} else {
promise = Promise.all([
destroy.call(this._encrypted, opts),
destroy.call(this, opts)
])
}
return cbify(promise, callback)
}
}

0 comments on commit c0c68be

Please sign in to comment.