SamVerschueren / dynongo

MongoDB like syntax for DynamoDB
MIT License
58 stars 16 forks source link

feat: use ADD for $inc #84

Closed onhate closed 3 years ago

onhate commented 4 years ago

Expressions.UpdateExpressions.ADD

onhate commented 4 years ago

codecov decreased because lines of code reduced too.

onhate commented 3 years ago

@SamVerschueren what do you think about this feature?

onhate commented 3 years ago

@SamVerschueren ?

SamVerschueren commented 3 years ago

Hi @onhate. Sorry about the delay.

I noticed the following comment in the docs though.

image

Not sure why, it's not really explained. The change for using ADD should behave exactly the same as what we had with SET, right? The only benefit is that we don't have to generate the _v_empty_value?

onhate commented 3 years ago

🤔 that's weird, I think they meant that because ADD can have different behaviors if using it with sets or numbers which could cause confusion, like trying to create a set with a number and instead it creates a number field, but on our case we have clear operations for sets($addToSet, $removeFromSet) and numbers ($inc) that will enforce the creation of a set or a numeric value.

Correct, the main benefit is to remove the extra overhead of checking if exists or not and the _empty_value.