I have a Notification Schema which includes an array of recipients
. If a Notification documents' recipients
array becomes empty, then I want it to be automatically deleted.
Is this possible? Thanks
This is not possible within Mongoose. I would suggest when you remove the final recipient, check if the array is empty then delete the document. This might be a useful stack overflow post if you want to delete all documents where the recipient array is empty: Find MongoDB records where array field is not empty