Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A method which returns the raw DynamoDB params for creating an item #172

Open
aneilbaboo opened this issue Dec 10, 2018 · 0 comments
Open

Comments

@aneilbaboo
Copy link
Contributor

aneilbaboo commented Dec 10, 2018

This is a feature proposal to add a new function Table.prototype.createParams which will return the validated, processed parameters required to create the item using the DynamoDB API. It would behave like this:

const item = new MyItem({....});
item.createParams((err, params) => {
   // params have been validated by schema and processed by `create` hook 
   // do something with params
});

Why

AWS Data Pipeline provides a helpful solution for the hard-ish problem of bulk loading data into DynamoDB. It reads JSON files from S3 and throttles the rate at which data is written to DynamoDB.

References:

https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBPipeline.html

http://eng.hakopako.net/entry/2016/08/22/100000

It would be nice to use Dynogels models schema validation and data processing to generate the required JSON.

Proposal

I think this should be straightforward. Look here in internals.createItem in table.js. I think we just want to return params without calling sendRequest.

So, here is what I'm proposing, specifically. I'd be willing to take a crack at it if it's acceptable.

  1. Separate the code in internals.createItem before sendRequest into a new function internals.makeCreateItemParams, and call this inside internals.createItem
  2. Add a new function Table.prototype.createParams() which returns the value from internals.makeCreateItemParams

(Maybe do the same for updateItem and deleteItem too).

@aneilbaboo aneilbaboo changed the title Output to JSON suitable for S3 import A method which returns the raw DynamoDB params for creating an item Dec 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant