When using viaSave if there is a validation in the database and it fails, I get "MongoError: the update operation document must contain atomic operators.".
Eg:
mySchema.pre('validate', function(next) { let self = this; if (self.socialNetworks.length > 1) { self.invalidate('socialNetworks', 'Up to 1 social network can be saved.', self.socialNetworks); } next(); });
When using viaSave if there is a validation in the database and it fails, I get "MongoError: the update operation document must contain atomic operators.".
Eg:
mySchema.pre('validate', function(next) { let self = this; if (self.socialNetworks.length > 1) { self.invalidate('socialNetworks', 'Up to 1 social network can be saved.', self.socialNetworks); } next(); });
and
user.socialNetworks = ["www.facebook.com", "www.twitter.com"]; transaction.update(doc.user, doc.user.toObject()).options({viaSave: true});