Meteor-Community-Packages / meteor-simple-schema

Meteor integration package for simpl-schema
https://github.com/Meteor-Community-Packages/meteor-simple-schema
MIT License
920 stars 162 forks source link

Two fields have autovalues, one overrides the other #684

Closed cosmin-novac closed 7 years ago

cosmin-novac commented 7 years ago

Two of the fields in my collection have an autovalue, "score" and "rank". The rank field uses the value of the score field for its calculation.

Whenever I run clean(), I first see the correct value of score in the console, but this is then overridden as soon as the logs of the rank autovalue come up.

Please see this issue for code and more details.

aldeed commented 7 years ago

Yeah, autovalue isn't a great solution here. You can't predict the order in which they will run. I suggest a pre-save hook or some other solution outside of the schema.