A simple utility to model, import, query and test your data in your DynamoDB by adopting AWS DynamoDB Data Modelling Best practices (Single Table principle)
Easily run Test-First Migration approach for quick iteration to validate your model against your access pattern
- NodeJS
- Run Local DynamoDB https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html
- Go over to index.js and understand the sample code there
- Update the configuration, and run the sample code (node index.js)
- It will import the csv data in northwind folders
- Validate your model by running queries for your access patterns
- Repeat as many as you like by simply changing table name or use your own data / csv file
const tableName = 'northwind5';
let dynamo = new DynamoUtils (awsConfig,tableName,true);
Review the importAll() function and change to include/exclude csv, and set the keys to follow your access pattern
//prepare configuration: where to get the data, what to import
const dataPath = "./northwind/csv"; //folder of csv to import
const entities = ['customers','employees','orders','products','suppliers']; //list of entities to import
const rels = ['order_details']; //list to rel table to import (many to many)
const dataKeys = { //what values to be placed in the GSI to match your access pattern
'customers': ['companyName'],
'employees': ['lastName','reportsTo'],
'orders': ['customerID','orderDate'],
'products': ['supplierID'],
'suppliers': ['country','city'],
'order_details': ['quantity']
}
const keys = { //key or id for each entities
'customers': 'customerID',
'employees': 'employeeID',
'orders': 'orderID',
'products': 'productID',
'suppliers': 'supplierID',
}
importAll(dynamo);
dynamo.getAll('customers',(result)=>{
console.log (JSON.stringify(result));
}
);
and many others example in index.js