Ich muss meine dynamo db Tabelle aktualisieren, indem ich nur den Partitionsschlüssel verwende. Aber ich habe Validierung Ausnahme. Ich habe eine Tabelle mit 3 Feldern erstellt.Kann Dynamo Db Tabelle nicht aktualisieren, ValidationException erhalten
- id (Partition Key)
- Name (Sort Key)
- Alter
Dann i triyed habe Altes Feld mit nur id zu aktualisieren. (Tryied Alter von 30 bis 40 zu ändern) das ist mein Code
var AWS = require("aws-sdk");
AWS.config.update({
region: "us-east-1",
});
var params = {
TableName: 'test',
Key: { id: '100' },
UpdateExpression: 'set #age = :age ',
ConditionExpression: '#age = :testAge',
ExpressionAttributeNames: { '#age': 'age' },
ExpressionAttributeValues: { ':age': '40', ':testAge': '30' }
};
var docClient = new AWS.DynamoDB.DocumentClient();
docClient.update(params, function (err, data) {
if (err) {
console.log(err);
}
else {
console.log(data);
}
});
Aber ich habe Fehler wie folgt.
{ [ValidationException: The provided key element does not match the schema]
message: 'The provided key element does not match the schema',
code: 'ValidationException',
time: Thu Nov 17 2016 22:38:01 GMT+0530 (IST),
requestId: '34PNMFM6CEACQIRHTSV77OI0JRVV4KQNSO5AEMVJF66Q9ASUAAJG',
statusCode: 400,
retryable: false,
retryDelay: 0 }
Nach Fehler bekommen, ich meine params Variable wie diese diese
var params = {
TableName: 'test',
Key: { id: '100',name: 'manaf' },
UpdateExpression: 'set #age = :age ',
ConditionExpression: '#age = :testAge',
ExpressionAttributeNames: { '#age': 'age' },
ExpressionAttributeValues: { ':age': '40', ':testAge': '30' }
};
Mit geänderter wird updation erfolgreich abgeschlossen. Wie aktualisiert man Tabellen ohne Sortierschlüssel?