[英]When is my document saved using Mongoose save function?
My question is in the function below in the commented code. 我的问题在注释代码下面的函数中。
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?
});
As soon as the code is executed it is saved. 一旦执行代码,便将其保存。 There is some validation that occurs in the middleware, but it is instant otherwise.
中间件中会发生一些验证,但否则会立即生效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.