我是
javascript和node.js的新手,并且想知道有人可以帮助我找出通过其node.js SDK将新项目放在AWS Dynamodb上的现有表上的语法.这是我到目前为止.有什么我想要做的例子吗?如果有人能指出我正确的方向,那将是非常感激的.
var AWS = require('aws-sdk'); AWS.config.loadFromPath('./config.json'); AWS.config.update({region: 'us-east-1'}); var dynamodb = new AWS.DynamoDB(); var item = { // I need to put the an item with a the primary key of "id",and an attribute called "item" // I'm new to js and node.js,so if somebody could help me understand the documentation // http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/frames.html#!http%3A//docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB_20120810.html } dynamodb.putItem({TableName: 'log_dev',Item: item},function(err,data){ if (err) { console.log(err); // an error occurred } else { console.log(data); // successful response } });
解决方法
dynamoDB.putItem( { "TableName": "Table1","Item": { "Color": {"S": "white"},"Name": {"S": "fancy vase"},"Weight": {"N": "2"},"LastName":{"S": "Kumar"} } },function(result) { result.on('data',function(chunk) { console.log("" + chunk); }); }); console.log("Items are succesfully ingested in table ..................");