searchByKeywors(attrName, value){
var params = {
TableName: "products",
Key:{ attrName: value }
};
docClient.get(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
}
});
}
I found it's really strange that the object key of Key value in params doesn't support dynamic value here, this solution is not the best method, if I found another method to do this, I will update later:
Updated code:
searchByKeywors(attrName, value){
var params = {
TableName: "products",
Key:{ "name": value }
};
docClient.get(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("GetItem succeeded:", JSON.stringify(data, null, 2));
}
});
}
No comments :
Post a Comment