Skip to content

Virtuals not called on update queries #5763

Open
@gcanu

Description

@gcanu

mongoose : 4.12.4
nodeJs : 8.2.1
mongoDB : 3.4.6

Hello,

Here's an enhancement purpose : currently, virtuals are not called when I use update queries like findByIdAndUpdate. You recently added a great feature : runSettersOnQuery but virtuals still not called. This because object contains update is casted before applySetters called, and fields that does not match model are removed...

I use virtual to make encryption/decryption on few fields, and it's not possible to use this very useful feature with update queries. It's possible to use save instead, but not always, especially when you have an object which contains new values...

Best regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureThis change adds new functionality, like a new method or class

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions