2016-11-24 40 views

回答

0

試試這個

var exportDocuments = function (db, callback) { 
    // Get the documents collection 
    var collection = db.collection('documents'); 
    // Find some documents 
    collection.find({}).toArray(function (err, docs) { 
     require('fs').writeFile('yourFileName.json', JSON.stringify(docs), function (error) { 
      if (error) return callback(error); 
      callback(); 
     }); 
    }); 
}