dynamodb-toolbox
dynamodb-toolbox copied to clipboard
Support hyphens in field names. Fixes #94
First off - thanks for this wonderful library. It's saved us a ton of time and simplified our code significantly. Well done!
This is a fix for #94.
I opted for a solution that allows users to pass an optional makeFieldName
option to Entity#update
, for example:
makeFieldName: (field, index) => `f_${index}`
This works too:
makeFieldName: (field) => field.replace(/-/g, '_')
It might be better to bake this into the library and always do the transformation (without passing makeFieldName
), but I thought this implementation might be better as a first step.
Thanks for this. I was in the middle of finishing up v0.3 which included a complete TS conversion, so I didn't get to merge this. That is live now, so I will review this soon.
Thanks @jeremydaly! There are many ways to skin this cat, so maybe you'd prefer a different solution.
Ideally there would be no makeFieldName
option, and the conversion would always happen internally.
Hey @aslakhellesoy, thanks for creating this PR and sorry for the delayed response.
In order to resolve this issue, the healthier way would be to switch the name building to to an incrementing numerical index approach like we used for the projectionBuilder.
I'll unfortunately close this PR for now but thanks for your time ❤️