Closed sean-hill closed 3 years ago
Hi @sean-hill ,
Unfortunately the plugin does not execute on updateMany
, See mongoose documentation here: https://mongoosejs.com/docs/middleware.html#notes
You will need to manually do a find - get the document, make your changes and then save it back again. A bit annoying yes, but it is a solution :)
@wheresvic sounds good. I'll redo my implementation to allow for that 😄
So something like this?
const doc = await model.findById(id)
doc.inputs = undefined
await doc.save()
@sean-hill
Yes, you might want to set it to an empty string to indicate that it was once filled but this is of course dependent on the design of your object :).
Cheers,
Hi! I'd like to remove an encrypted field from a document, but I'm not sure how to do it. In this case the
inputs
key would be the encrypted field. This is my best try so far: