javascript – 使用AWS SDK for Node.js将项目放在DynamoDB表上

前端之家收集整理的这篇文章主要介绍了javascript – 使用AWS SDK for Node.js将项目放在DynamoDB表上前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我是 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 ..................");
原文链接:https://www.f2er.com/js/151468.html

猜你在找的JavaScript相关文章