DynamoDB putItem in Javascript example

DynamoDB requires a custom JSON format – this will convert a POJO to that format and save it, returning a promise:

dynamodb.putItem({
  Item: AWS.DynamoDB.Converter.marshall(recordToSave),
   TableName: tables[type]
}).promise()

Note that if you use dates, you’ll need to first marshal them to a suitable format (number or string) and un-marshal them on the way out.