I'm unclear about the new
keyword in node.js. I know it basically create an instance of my schema. But why I don't need to declare new
when I do an update? so my question is when to use new
here.
var User = module.exports = mongoose.model('tokens', userSchema);
//route endpoint here
..
new User({user: user_id, data: data}).save(callback);
If I don't use new in above code what will happens? the flow of the code make sense even if I don't. Correct me if I'm wrong, thanks.