Last active
August 29, 2015 13:56
-
-
Save daleharvey/9198141 to your computer and use it in GitHub Desktop.
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
// How it should be written | |
remote.bulkDocs({docs: docs}); | |
db.replicate.from(remote); | |
var docs = db.allDocs(); | |
res.total_rows.should.equal(num); | |
// No error handling | |
remote.bulkDocs({ docs: docs }, function (err, info) { | |
db.replicate.from(remote, {}, function () { | |
db.allDocs(function (err, res) { | |
res.total_rows.should.equal(num); | |
done(); | |
}); | |
}); | |
}); | |
// check every err | |
remote.bulkDocs({ docs: docs }, function (err, info) { | |
if (err) return done(err); | |
db.replicate.from(remote, {}, function (err) { | |
if (err) return done(err); | |
db.allDocs(function (err, res) { | |
if (err) return done(err); | |
res.total_rows.should.equal(num); | |
done(); | |
}); | |
}); | |
}); | |
// bind every callback | |
remote.bulkDocs({ docs: docs }, bindSuccess(done, function (err, info) { | |
db.replicate.from(remote, {}, bindSuccess(function (err) { | |
db.allDocs(bindSuccess(function (err, res) { | |
if (err) return done(err); | |
res.total_rows.should.equal(num); | |
done(); | |
})); | |
})); | |
})); | |
// promises | |
remote.bulkDocs({docs: docs}).then(function() { | |
return db.replication.from(remote); | |
}).then(function() { | |
return db.allDocs(); | |
}).then(function(res) { | |
res.total_rows.should.equal(num); | |
done(); | |
}).catch(done); |
nick-thompson
commented
Feb 24, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment