Commit 70fc609c authored by Vadym Gidulian's avatar Vadym Gidulian

Added deleting of multiple records

parent 16261f8f
......@@ -147,6 +147,21 @@ app.patch('/:collection/:id', (req, res) => {
});
});
});
app.delete('/:collection', (req, res) => {
mongoSafeConnect(res, client => {
client.db(DB_NAME).collection(req.params.collection).deleteMany(req.body.filter, (err, result) => {
if (err) throw err;
if (result.deletedCount) {
res.status(200).send();
} else {
res.status(404).send();
}
client.close();
});
});
});
app.delete('/:collection/:id', (req, res) => {
mongoSafeConnect(res, client => {
client.db(DB_NAME).collection(req.params.collection).findOneAndDelete({_id: toId(req.params.id)}, (err, result) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment