Skip to content

Instantly share code, notes, and snippets.

@nolanlawson
Forked from calvinmetcalf/ascript.js
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nolanlawson/11260929 to your computer and use it in GitHub Desktop.
Save nolanlawson/11260929 to your computer and use it in GitHub Desktop.
var start = document.getElementById('start');
var stuff = document.getElementById('stuff');
var remote = new PouchDB('http://registry.npmjs.org/', {cache: true});
var local = new PouchDB('npm');
start.addEventListener('click', function (){
remote.info().then(function (a) {
return a.doc_count;
}).then(function (count) {
remote.replicate.to(local, {
batch_size: 100
}).on('change', function (change) {
stuff.innerText = change.docs_written + ' out of ' + count;
}).on('complete', function () {
stuff.innerText = change.docs_written + ' done'
});
});
});
<div id="stuff"></div>
<button id="start">start</button>
<script src="//pouchtest.com/couchdb/pouchdb_builds/e8a764e9a58da8e8f26a069df5d75cc6f2acd8a7/pouchdb.min.js"></script>
<script src="ascript.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment