shiftcode / dynamo-easy

DynamoDB client for NodeJS and browser with a fluent api to build requests. We take care of the type mapping between JS and DynamoDB, customizable trough typescript decorators.
https://shiftcode.github.io/dynamo-easy/
MIT License
204 stars 27 forks source link

Easily update the tablename #337

Open andreujuanc opened 3 years ago

andreujuanc commented 3 years ago

Hi it's me! I'm checking out your library and it looks very promising. I almost got something working but:

Is your feature request related to a problem? Please describe. I needed to set the table name on run time, but I find cumbersome to call updateDynamoEasyConfig everywhere. I do not have a "central" entry-point, so this forces my code to create that central entry point. (im doing lambdas)

Describe the solution you'd like Since stores instances are per model. It'd be nice if we could override the values of the tablename here: https://github.com/shiftcode/dynamo-easy/blob/master/src/dynamo/dynamo-store.ts#L36 So i could do something like :

new DynamoStore(Profile, {
   tablename: 'users-stage-98754'
})

Describe alternatives you've considered I'm trying to set this up with updateDynamoEasyConfig but it makes my code ugly, and I cannot have it dangling since my code is serialized into a bundle, and because updateDynamoEasyConfig is not being referenced by the executing code it wont be deployed. I have similar issue in which I have to call require('reflect-metadata') because the import is not being taken into account. So basically I'll have to copy pasta that portion of the code on every handler, or "import" a common

Thanks