title: How do I execute the mongodump command programmatically from node.js?
body: <p>What is the best way to execute mongodb admin/console commands programmatically from node.js? Specifically, I would like to export a mongodb collection using mongodump after performing a series of inserts. Something like this:</p>
  
  <pre><code>// 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???
  
              });
          });
      }
  });
  </code></pre>