My question is similar to the one asked for java but need help with javascript aws-sdk. Couldn't find any examples.
the table structure would be as shown below:
customer:
customerId: '12345'
policies:
- policyNumber: 12345
status: active
You can try using DocumentClient.put()
see documentation. Below is a sample from my existing code updated to match your payload but I haven't tested it since I didn't want to pollute my table.
import AWS from 'aws-sdk';
const params = {
TableName: 'TBL_CUSTOMER', //or whatever your table name is
Item: {
customerId: '12345',
policies: {
policyNumber: 12345,
status: 'active'
}
}
};
const documentClient = new AWS.DynamoDB.DocumentClient();
const result = await new Promise((resolve, reject) => {
documentClient.put(params, function (err, data) {
if (err) reject(err);
else resolve(data);
});
});
console.log('result:', result);