gpt4 book ai didi

javascript - 使用适用于 Node.js 的 AWS 开发工具包将项目放在 DynamoDB 表中

转载 作者:IT老高 更新时间:2023-10-28 22:59:27 25 4
gpt4 key购买 nike

我是 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 ..................");

关于javascript - 使用适用于 Node.js 的 AWS 开发工具包将项目放在 DynamoDB 表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17767630/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com