Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

why is my mongoose middleware not working

DocSchema.pre('deleteOne', { document: true }, function() {
  console.log(this)
})

//You must first find the document before deleting it.
const doc = await DocSchema.findOne({ name: 'myDoc' })
await doc.deleteOne()
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mongoose #middleware #working
ADD COMMENT
Topic
Name
1+4 =