e-oj / Fawn

Transactions for MongoDB (See the README)
https://www.npmjs.com/package/fawn
MIT License
485 stars 54 forks source link

rollbackRemoveOrUpdate using viaSave #55

Open yamila-fraiman opened 6 years ago

yamila-fraiman commented 6 years ago

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

e-oj commented 6 years ago

I'll look into it. Might be related to #53

e-oj commented 5 years ago

After much digging, this is actually related to #74

yamila-fraiman commented 5 years ago

Hi I'm still having this problem with version 2.1.5. Any update?