irl_irl
irl_irl

Reputation: 3975

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?
            });

Upvotes: 0

Views: 32

Answers (1)

James Freund
James Freund

Reputation: 483

As soon as the code is executed it is saved. There is some validation that occurs in the middleware, but it is instant otherwise.

Upvotes: 1

Related Questions