How to delete all JSON in MongoDB collections using rest API?
router.delete('/:id', async(req, res)=> {
const delbyid = await persons.deleteOne();
res.status(200).json(delbyid);
})
The deleteOne and deleteMany methods exist in the Collection class and are used to remove documents from MongoDB.
Use persons.deleteMany({});