Open naerbnic opened 6 years ago
That sounds like a reasonable use case. Can it be solved with the feature to add an external dynamodb instance?
From the README.md:
You can also pass in a custom instance of the aws-sdk DynamoDB client
var dynamodb = new AWS.DynamoDB();
Account.config({dynamodb: dynamodb});
// or globally use custom DynamoDB instance
// all defined models will now use this driver
dynogels.dynamoDriver(dynamodb);
This is a useful and interesting feature. Bluebird has a similar thing that we use to augment the promise prototype with our own methods, without polluting Bluebird for any other modules that use it. As much as possible, I think Node modules should provide factories to produce new and independent module instances.
I will try to work on this over the next month or so.
FWIW, that would be definitely a nice way to hook in a dynamodb-local instance for testing purposes.
Currently when you're configuring dynogels, you call a module-global method to initialize the configuration state:
While convenient, this makes it difficult to run independent configurations, such as may be necessary with either multiple regions or with tests that point to local implementations.
I propose we add a factory method that constructs independent dynogels modules, as many other modules do. With a bike-sheddable interface:
This module is independent of others created with
createWithConfig()
, and global changes to configuration do not affect it.The dynogels module itself would not change it's API for purposes of compatibility, so the first code block above would still operate as expected.