0
私はmongooseとmongoose-gridfsモジュールを使用していますが、エラーを修正する方法を理解できません。 は簡単に私のデシベルにファイルを追加し、それを読むことができます:Gridfsファイルの削除エラー
router.get('/:id', (req, res)=> {
if (gridfs == null) {
gridfs = require("mongoose-gridfs")({
collection: 'attachments',
model: 'Files'
});
Attachment = gridfs.model;
}
let stream = Attachment.readById(req.params["id"]);
}
しかし、私は削除ルートで同じ方法を使用しています:
router.delete('/:id', (req, res)=> {
if (gridfs == null) {
gridfs = require("mongoose-gridfs")({
collection: 'attachments',
model: 'Files'
});
Attachment = gridfs.model;
}
Attachment.unlinkById(req.params["id"], (err) => {
});
}
それは私にエラーTypeError例外を投げるです:プロパティを読み取ることができません "ヌルのリンクを解除する。 何が間違っていますか?以下に示すように、変数を「gridfs」初期化すると「マングース-gridfs」を必要とするが、あなたのマングースの接続に渡してみてください