Last active
August 29, 2015 14:06
-
-
Save redgeoff/f261e0cca0515e0736d0 to your computer and use it in GitHub Desktop.
PouchDB - destroy not deleting couch database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<script src="//cdn.jsdelivr.net/pouchdb/3.0.5/pouchdb.min.js"></script> | |
</head> | |
<body> | |
<script> | |
var db = new PouchDB('test_destroy'), | |
remoteCouch = 'http://127.0.0.1:5984/test_destroy', | |
opts = { live: true }; | |
function error(err) { | |
console.log('error=' + err); | |
} | |
function syncError(err) { | |
console.log('syncError=' + err); | |
} | |
db.on('error', error); | |
db.replicate.to(remoteCouch, opts, syncError) | |
.on('change', function (info) { | |
console.log('to.change='); | |
console.log(info); | |
}).on('complete', function (info) { | |
console.log('to.complete=' + info); | |
}).on('uptodate', function (info) { | |
console.log('to.uptodate='); | |
console.log(info); | |
}).on('error', function (err) { | |
console.log('to.error=' + err); | |
}); | |
db.replicate.from(remoteCouch, opts, syncError) | |
.on('change', function (info) { | |
console.log('from.change='); | |
console.log(info); | |
}).on('complete', function (info) { | |
console.log('from.complete=' + info); | |
}).once('uptodate', function (info) { | |
console.log('from.uptodate='); | |
console.log(info); | |
destroy(); | |
}).on('error', function (err) { | |
console.log('from.error=' + err); | |
}); | |
db.on('destroyed', function () { | |
console.log('done destroying'); | |
}); | |
function destroy() { | |
db.destroy().then(function () { | |
console.log('after destroy()'); | |
}).catch(function (err) { | |
console.log('destroy err=' + err); | |
}); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment