本文介绍了dynamodb节点AWS-SDK简单的getItem()调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
伙计们,新的JavaScript ...试图从节点做简单的发电机查询:
Folks, New to Javascript... trying to do simple dynamo queries from node:
var AWS = require('aws-sdk');
AWS.config.update({region: 'us-east-1'});
var db = new AWS.DynamoDB();
var params = {
"TableName" : 'admins',
"Key" : [
{ "username" : { "S" : "foo" } },
],
}
db.getItem(params, function(err, data) {
console.log('error: '+ err);
console.log(data);
return next();
res.send(data);
});
}
输出:
error: UnexpectedParameter: Unexpected key 'username' found in params.Key['0']
谢谢!任何帮助将大大AP preciated!
Thanks! Any help would be greatly appreciated!
推荐答案
必须遵循的SDK和文档,其简单的:的
Must follow the SDK and Docs, its simple:http://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_GetItem.html
var params = {
AttributesToGet: [
"password"
],
TableName : 'foo',
Key : {
"username" : {
"S" : "bar"
}
}
}
db.getItem(params, function(err, data) {
if (err) {
console.log(err); // an error occurred
}
else {
console.log(data); // successful response
res.send(data);
}
return next();
});
这篇关于dynamodb节点AWS-SDK简单的getItem()调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!