阅读背景:

在发送到Mongoose的客户端之前操作查询的数据库文档被认为是不好的做法吗?

来源:互联网 

So I spent too long trying to figure out how to manipulate a returned database document (using mongoose) using transform and virtuals, but for my purposes, those aren't options. The behaviour I desire is very similar to that of a transform (in which I delete a property), but I only want to delete the property from the returned document IFF it satisfies a requirement calculated using the req.session.user/req.user object (I'm using PassportJS, but any equivalent session user suffices). Obviously, there is no access to the request object in a virtual or transform, and so I can't do the calculation.So I spent too long trying to figure out how to




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: