admin管理员组文章数量:1419189
how do i update item in dynamoDB using nodejs ?
here is the ITEM list from DynamoDB javascript shell -
"Items": [
{
"EmailId": "[email protected]",
"flag": 1,
"deviceOS": "IOS",
"panyName": "VCC",
"snsEndpoint": "00d0sadas",
"CreatedAt": 22112015,
"Otp": "ABCDEF",
},
i want to update flag value to 2 ... this is my code . what do i do?? what am i doing wrong ?? help is appreciated...
var params = {
TableName: 'users',
Key: {
id: {
'S': req.query.id
},
flag: {
'N': 2
}
},
UpdateExpression: 'SET #flag =:val1',
ExpressionAttributeNames: {
'#flag': 'flag' //COLUMN NAME
},
ExpressionAttributeValues: {
':val1': {
'N': 2
},
}
};
dynamodb.updateItem(params, function(err, data) {
if (err) {
console.log('Error :' + err);
} else {
//subscribe(bodydata.id);
console.log('EndpointArn Saved successful');
console.log('Data :' + JSON.stringify(data.flag));
}
});
how do i update item in dynamoDB using nodejs ?
here is the ITEM list from DynamoDB javascript shell -
"Items": [
{
"EmailId": "[email protected]",
"flag": 1,
"deviceOS": "IOS",
"panyName": "VCC",
"snsEndpoint": "00d0sadas",
"CreatedAt": 22112015,
"Otp": "ABCDEF",
},
i want to update flag value to 2 ... this is my code . what do i do?? what am i doing wrong ?? help is appreciated...
var params = {
TableName: 'users',
Key: {
id: {
'S': req.query.id
},
flag: {
'N': 2
}
},
UpdateExpression: 'SET #flag =:val1',
ExpressionAttributeNames: {
'#flag': 'flag' //COLUMN NAME
},
ExpressionAttributeValues: {
':val1': {
'N': 2
},
}
};
dynamodb.updateItem(params, function(err, data) {
if (err) {
console.log('Error :' + err);
} else {
//subscribe(bodydata.id);
console.log('EndpointArn Saved successful');
console.log('Data :' + JSON.stringify(data.flag));
}
});
Share
Improve this question
asked Nov 22, 2015 at 18:27
Vinayak IyerVinayak Iyer
531 gold badge1 silver badge10 bronze badges
0
1 Answer
Reset to default 2You are trying to modify the flag: { 'N': 2 }
which doesnot exist. But you wanted to modify the flag: { 'N': 1 }
value to 2. So try doing like this:
var params = {
TableName: 'users',
Key: {
id: {
'S': req.query.id
},
flag: {
'N': 1
}
},
UpdateExpression: 'SET #flag =:val1',
ExpressionAttributeNames: {
'#flag': 'flag' //COLUMN NAME
},
ExpressionAttributeValues: {
':val1': {
'N': 2
},
}
};
dynamodb.updateItem(params, function(err, data) {
if (err) {
console.log('Error :' + err);
} else {
//subscribe(bodydata.id);
console.log('EndpointArn Saved successful');
console.log('Data :' + JSON.stringify(data.flag));
}
});
本文标签: javascripthow to update item in dynamoDB using nodejsStack Overflow
版权声明:本文标题:javascript - how to update item in dynamoDB using nodejs? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745304947a2652588.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论