dynamodb-toolbox icon indicating copy to clipboard operation
dynamodb-toolbox copied to clipboard

Support hyphens in field names. Fixes #94

Open aslakhellesoy opened this issue 4 years ago • 2 comments

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.

aslakhellesoy avatar Dec 09 '20 09:12 aslakhellesoy

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.

jeremydaly avatar Dec 12 '20 23:12 jeremydaly

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.

aslakhellesoy avatar Dec 13 '20 20:12 aslakhellesoy

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 ❤️

naorpeled avatar Dec 02 '22 09:12 naorpeled