Cách tốt nhất để thực thi các lệnh quản trị/giao diện mongodb lập trình từ node.js là gì? Cụ thể, tôi muốn xuất một bộ sưu tập mongodb bằng cách sử dụng mongodump sau khi thực hiện một loạt các chèn. Một cái gì đó như thế này:Làm cách nào để thực thi lệnh mongodump lập trình từ node.js?
// 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???
});
});
}
});
Đã hoạt động tốt. Cảm ơn. – TankofVines