据我所知,猫鼬预保存钩子在文档插入集合之前触发,但在验证发生之后。因此,如果一个验证失败,则不会调用预保存钩子。添加了预保存钩子,以自动推送新用户在推荐列表中的in。result.referred.length); // 2, which is BAD });});
所有其他检查,错误抛出,失败发生,但所有预保存钩子都保存不管或者在验证之后是否有一个
试图通过docs/blog(Tim)来理解猫鼬中间件(pre/save/并行)。var schema = new Schema(..); // calling next kicks off the next middleware in parallel doAsync(done);
The hooked method, in this case save, will not be executed until done is calle