13
从node.js以编程方式执行mongodb admin/console命令的最佳方法是什么?具体来说,我想在执行一系列插入操作后使用mongodump导出一个mongodb集合。事情是这样的:如何从node.js以编程方式执行mongodump命令?
// requires and initializing stuff left out for brevity
db.open(function(err, db) {
if(!err) {
db.collection('test', function(err, collection) {
var docs = [{'hello':'doc1'}, {'hello':'doc2'}, {'hello':'doc3'}];
collection.insert(docs, {safe:true}, function(err, result) {
// Execute mongodump in this callback???
});
});
}
});
工作得很好。谢谢。 – TankofVines 2012-04-18 17:29:48