I created a table 'user_info' in dynamoDB with one primary hash key 'user_id'(String), no range key. Then I created 2 aws lambda function to insert and query the items. I can insert items into the table, but when I query the table, it returns a ValidationException: The provided key element does not match the schema. My query function :
var params = {
Key: {
user_id:{
S: "usr1@s.com"
}
},
TableName: 'user_info',
ProjectionExpression: 'password'
};
dynamodb.getItem(params,
function(err, data) {
if (err) {
console.log("get item err." + err);
context.done('error','getting item from dynamodb failed: '+err);
}
else {
console.log('great success: '+JSON.stringify(data, null, ' '));
context.succeed('created user ' + event.user_id + ' successfully.');
}
});
I keep getting this exception:
ValidationException: The provided key element does not match the schema
Since 1)I have only one hash primary key. 2)user_id is defined as String. I really don't know why there is a mismatch error.
Aucun commentaire:
Enregistrer un commentaire