I use an array of strings to save emails:
var user = new Schema({
emails: [String]
});
You have problems updating this field. Let's say email1 and email2 are the values that I get from the view:
This works well:
user.emails = [email1, email2];
user.save();
And this is not so:
user.emails[0] = email1;
user.emails[1] = email2;
user.save(function(err, savedUser) {
console.log(savedUser.emails);
});
But, oddly enough, this works:
user.emails = [email1];
user.emails[1] = email2;
user.save();
Can someone explain why this is happening?
eagor source
share