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
The last line causes an error that vaguely says the the createdAt property is invalid, which leads one to believe that the issue relates to the type, value, or something similar--not the implicit addition of the property. I spent about an hour trying to figure out why my data wasn't passing validation.
One workaround is to construct the autoValue method as follows:
function () {
if (this.isInsert) {
return new Date();
}
}
However, if I wanted to do it that way, I might as well just throw an error when the property was explicitly defined outside of an insertion operation, which obviously defeats the purpose of this package.
Personally, I wouldn't expect autoValue to be called during an update operation when denyUpdate is set to true. I can't conceive of any reasonable use cases in which such behavior would be desirable.
The text was updated successfully, but these errors were encountered:
Since this is an add-on package, we can't prevent autoValue from running. The workaround of checking isInsert is the right way to do it, but it doesn't solve the issue for defaultValue. I will leave this open in case anyone can figure out an elegant solution, but this is one of the reasons that I don't personally use or recommend using denyInsert or denyUpdate. There are better ways to handle security.
Consider the following example:
The last line causes an error that vaguely says the the
createdAt
property is invalid, which leads one to believe that the issue relates to the type, value, or something similar--not the implicit addition of the property. I spent about an hour trying to figure out why my data wasn't passing validation.One workaround is to construct the
autoValue
method as follows:However, if I wanted to do it that way, I might as well just throw an error when the property was explicitly defined outside of an insertion operation, which obviously defeats the purpose of this package.
Personally, I wouldn't expect
autoValue
to be called during an update operation whendenyUpdate
is set totrue
. I can't conceive of any reasonable use cases in which such behavior would be desirable.The text was updated successfully, but these errors were encountered: