DynamoDB NodeJS
Here’s an example of how you can do this:
First, you need to install the AWS SDK:
npm install aws-sdk
Then, you can interact with DynamoDB. The following is an example of how to create a table in DynamoDB:
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
// Set the region
AWS.config.update({region: 'REGION'}); // replace 'REGION' with your region, e.g. 'us-west-2'
// Create the DynamoDB service object
var ddb = new AWS.DynamoDB({apiVersion: ‘2012-10-08’});
var params = {
AttributeDefinitions: [
{
AttributeName: ‘CUSTOMER_ID’,
AttributeType: ‘N’
},
{
AttributeName: ‘CUSTOMER_NAME’,
AttributeType: ‘S’
}
],
KeySchema: [
{
AttributeName: ‘CUSTOMER_ID’,
KeyType: ‘HASH’,
},
{
AttributeName: ‘CUSTOMER_NAME’,
KeyType: ‘RANGE’,
}
],
ProvisionedThroughput: {
ReadCapacityUnits: 5,
WriteCapacityUnits: 5
},
TableName: ‘CUSTOMER_LIST’,
StreamSpecification: {
StreamEnabled: false
}
};
// Call DynamoDB to create the table
ddb.createTable(params, function(err, data) {
if (err) {
console.log(“Error”, err);
} else {
console.log(“Table Created”, data);
}
});
Remember to replace ‘REGION’ with your actual region, and modify the parameters to meet your requirements.
Demo Day 1 Video:
Conclusion:
Unogeeks is the No.1 IT Training Institute for Amazon Web Services (AWS) Training. Anyone Disagree? Please drop in a comment
You can check out our other latest blogs on Amazon Web Services (AWS) Training here – AWS Blogs
You can check out our Best In Class Amazon Web Services (AWS) Training Details here – AWS Training
Follow & Connect with us:
———————————-
For Training inquiries:
Call/Whatsapp: +91 73960 33555
Mail us at: info@unogeeks.com
Our Website ➜ https://unogeeks.com
Follow us:
Instagram: https://www.instagram.com/unogeeks
Facebook:https://www.facebook.com/UnogeeksSoftwareTrainingInstitute
Twitter: https://twitter.com/unogeeks