diff --git a/src/routes/material.ts b/src/routes/material.ts index 4fb4bad..a75f73d 100644 --- a/src/routes/material.ts +++ b/src/routes/material.ts @@ -122,7 +122,8 @@ router.delete('/material/' + IdValidate.parameter(), (req, res, next) => { if (!req.auth(res, ['write', 'dev', 'admin'], 'basic')) return; // check if there are still samples referencing this material - SampleModel.find({'material_id': new mongoose.Types.ObjectId(req.params.id)}).lean().exec((err, data) => { + SampleModel.find({'material_id': new mongoose.Types.ObjectId(req.params.id), status: {$ne: globals.status.del}}) + .lean().exec((err, data) => { if (err) return next(err); if (data.length) { return res.status(400).json({status: 'Material still in use'});