I have got stuck in a problem about deleteOne method of Mongoose.
The problem is as follows:
- deleted a document by using deleteOne() with a key.
- tried to delete the same document by using deleteOne() with the same key again, and then the method didn't return any error.
The code that I wrote is here.
Is it possible to get an error somehow?
I would be grateful if you could solve this problem. Thank you in advance.
Mongodb (npm used by you mongoose) returns following with deleteOne when deleting a document with key and it exists:
In case, when you delete the same document which was already deleted it returns:
So, modify your code as below:
Mongo Shell Output for reference: