vogels
vogels copied to clipboard
Update serializer ignores `$add: 0`
Hey there,
According to the DynamoDB spec, if a non-existing attribute is $add-ed to, it will be created, init to 0, then the passed value will be added.
I'm trying to leverage this to use a single update call to either init a value to 0 (using $add: 0
) or incrementing it if the passed value > 0.
However, the serializer is doing a truthy / falsey comparison here: https://github.com/ryanfitz/vogels/blob/3e6747ca2f37676ce866caa9a34d89ce4254e34c/lib/serializer.js#L185
I worked around by using { $add: new Number(myInput) }
, but I feel others might hit this issue as well, when trying to $add: 0
.
So just in case you don't get a chance to fix the bug, I'm submitting this issue for future reference :)
Thanks for the great work so far on vogels!