You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When performing an update with an empty modifier {}, it passes validation and then Meteor treats it as an literal document and replaces the document with the empty one.
This certainly feels like a bug, but in reality it is the way that Mongo updates work without any validation attached. Still, if you do attach validation, it makes sense that you might want to be warned about this. Not sure exactly what this would look like off the top of my head, but I guess some way to inform it that you explicitly want to allow a whole-document update?
When performing an update with an empty modifier
{}
, it passes validation and then Meteor treats it as an literal document and replaces the document with the empty one.I've got a very simple setup:
To illustrate, I'll create a test document in meteor shell:
Tests with modifiers that violate the schema fail:
Tests with literal documents fail validation:
But passing in the empty modifier:
Wipes the document:
Is this a bug?
What's the recommended way of preventing this? Should I extend and overload update to check for empty objects?
The text was updated successfully, but these errors were encountered: