键上的条件数是无效的节点js的发电机数据库
docClient.update({ TableName: 'patient', Key: { "patientId": "TIGERPAT0001" }, UpdateExpression: "set title = :x, name = :y", ExpressionAttributeNames: { "#name": "name" }, ExpressionAttributeValues: { ":x": 'title value abc', ":y": 'name value xyz' } }, function (err, data) { if (err) { json.status = '0'; json.result = { 'error': 'Unable to Edit Patient : ' + JSON.stringify(err) }; res.send(json); } else { json.status = '1'; json.result = { 'sucess': 'Patient Edited Successfully :' }; res.send(json); } });
当使用上面的代码时,我得到了res:
无法编辑患者错误:{“message”:“密钥条件数无效”,“code”:“ValidationException”,“time”:“2017-09-13T07:12:56.608Z”,“requestId “:” a01c707c-86b4-41a5-a1c5-92b9ea07c026" , “的StatusCode”:400, “重试”:假的, “retryDelay”:6.368631970657979}
我想念/任何错误?
我觉得你在创build表的时候使用了多个键。
如果你在创build表的时候使用了n
个键,那么你还需要传递n
个键:
例如:
docClient.update({ TableName: 'patient', Key: { "patientId": "TIGERPAT0001", "id1": "id1value", "id2": "id2value" }, UpdateExpression: "set title = :x, name = :y", ExpressionAttributeNames: { "#name": "name" }, ExpressionAttributeValues: { ":x": 'title value abc', ":y": 'name value xyz' } }, function (err, data) { if (err) { json.status = '0'; json.result = { 'error': 'Unable to Edit Patient : ' + JSON.stringify(err) }; res.send(json); } else { json.status = '1'; json.result = { 'sucess': 'Patient Edited Successfully :' }; res.send(json); } });
请用您的密钥replaceid1
和id2
- 你如何unit testing一个NodeJs的Lambda函数写入/读取dynamodb,并通过AWS API网关端点调用?
- 如何使用Lambda和DynamoDB在date范围之间扫描?
- 使用nodejs Dynamodb创build表?
- 在Dynamo dB的获取操作中,“在参数中缺less必需的键”键
- DynamoDB Local在closures实例后删除数据
- 如何使用DynamoDB批量删除?
- AWS DynamoDB问题:用户无权在资源上执行:dynamodb:PutItem
- DynamoDB Javascript – 通过主键和范围键数组查询?
- 查询条件丢失关键架构元素:validation错误