mongodb-backup
mongodb-backup copied to clipboard
Why nest promises instead of use return value?
It seems messy to do this:
tasks.mongodump().then(function () {
tasks.zip(config.database, path.join(__dirname, 'dump')).then(function (filepath) {
tasks.s3(filepath).then(function () {
tasks.clean(filepath).then(tasks.clean(path.join(__dirname, 'dump', config.database))).then(function () {
utils.log('debug', 'Done.');
}).catch(function (ex) {
utils.log('error', ex);
});
}).catch(function (ex) {
utils.log('error', ex);
});
});
});
When you can do this:
tasks.mongodump().then(function () {
return tasks.zip(config.database, path.join(__dirname, 'dump'))
}).then(function (filepath) {
return tasks.s3(filepath)
}).then(function () {
return tasks.clean(filepath)
}).then(function () {
return tasks.clean(path.join(__dirname, 'dump', config.database))
}).then(function () {
utils.log('debug', 'Done.');
}).catch(function (ex) {
utils.log('error', ex);
})