Why are my Mongoose 3.8.7 schema getters and setters being ignored?

前端 未结 3 1986
情话喂你
情话喂你 2021-02-19 13:01

While working with Node.js, Mongoose and MongoDB, I have found that my Mongoose schema getters and setters do not fire when I perform a findOne query.

I have found an ol

3条回答
  •  盖世英雄少女心
    2021-02-19 13:42

    Are you assuming virtuals are not working because they don't show up in your console.log output? If so, that is by design. Virtuals are external to your actual document so do not get printed with console.log by default. To get them to display, read these docs: http://mongoosejs.com/docs/api.html#document_Document-toObject

提交回复
热议问题