From 8f88023da24308f31acf62438ca37615f30e510f Mon Sep 17 00:00:00 2001 From: VLE2FE Date: Mon, 31 Aug 2020 14:51:43 +0200 Subject: [PATCH] fixed deleting materials --- src/routes/material.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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'});