Open AdamGerthel opened 3 years ago
This should work already as long as you set the lean
option to false
.
@daffl I've read that too somewhere, but it doesn't! I've tried every possible way/setting/option.
Ideally we'd need an example of what isn't working as expected then.
Yep, I totally get that. Will see if I get time to throw together a small repro repo.
Feature request
Support document middleware
Background
AFAIK, document middleware, such as mongoose pre-save hooks, are not supported. I'm assuming that this is because feathers-mongoose uses queries such as
findOneAndUpdate()
rather than loading the document and then saving it (see https://mongoosejs.com/docs/middleware.html#notes).As suggested in other issues, it's possible, and often recommended, to utilise Feathers service hooks instead. However, there are use cases when that option is not very fitting. An example is when you are re-using a single schema in several other schemas. Perhaps even nested on different levels in different models.
In such a use case, using service hooks would be very messy compared to a single, all-encompassing Mongoose pre validate/save/remove hook.