javascript - 我的文档何时使用 Mongoose 保存功能保存?

标签 javascript mongodb mongoose

我的问题在注释代码中的下面的函数中。

newUser = new User();
newUser.save(function(err){
            if(err) console.log('error saving user');
            // is my user saved at this point? Can I modify
            // the user in here or is this pre-save?
            });

最佳答案

代码一执行就会被保存。中间件中会发生一些验证,但否则是即时的。

关于javascript - 我的文档何时使用 Mongoose 保存功能保存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35211566/

相关文章:

java - 复合索引是否支持索引字段前缀的匹配?

mongodb - 无法创建 mongodb 数据库

node.js - 使用 mongoose 时,geoNear() 无法按预期工作

Javascript:如何捕获空的 Facebook Graph json 对象? --> { "data": [ ] }

javascript - 使用 JavaScript 连接 2 个具有不同主键的 JSON 对象

javascript - 如何在 Mongoose 中定义一个不同于 _id 的主键?

arrays - findOneAndUpdate 导致重复问题

node.js - 创建模型时出现 Mongoose 错误(使用步骤)

javascript - 将函数设置为 ng-model

javascript - MVC 列表转 jquery