1
var Grid = require('gridfs-stream');
var mongoose = require('mongoose');
var GridFS = Grid(mongoose.connection.db, mongoose.mongo);
GridFS.collection('dbmanager').remove({_id: mongoose.Types.ObjectId(req.file_id)}, function (err) {
console.log("deleted");
});
在這裏,我創建了一個集( 「dbmanager」)保存文件。當我嘗試從dbmanager集合中刪除文件時,文檔將從「dbmanager.files」中刪除。但文檔仍然顯示在「dbmanager.chunks」中。我需要從「dbmanager.files」和「dbmanager.chunks」中刪除這些文檔。