Update in DynamoDB not working with AWS Lambda

Refresh

March 2019

Views

5 time

0

I've managed to write a complete script in NodeJS in AWS Lambda, although I'm falling at the final hurdle when it comes to an update query, here's my code:

var update_params = {
    TableName:"matches",
    Key: { "match_id": match.id },
    UpdateExpression: "SET #status = :status, updated_at = :modified",
    ExpressionAttributeNames:{
        "#status":"status"
    },
    ExpressionAttributeValues:{
        ":status": 1,
        ":modified": modified
    }
};
await documentClient.update(update_params).promise();

And here's my annoying error that I can't seem to subside past:

{
  "errorMessage": "The provided key element does not match the schema",
  "errorType": "ValidationException",
  "stackTrace": [
    "Request.extractError (/var/runtime/node_modules/aws-sdk/lib/protocol/json.js:48:27)",
    "Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:105:20)",
    "Request.emit (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:77:10)",
    "Request.emit (/var/runtime/node_modules/aws-sdk/lib/request.js:683:14)",
    "Request.transition (/var/runtime/node_modules/aws-sdk/lib/request.js:22:10)",
    "AcceptorStateMachine.runTo (/var/runtime/node_modules/aws-sdk/lib/state_machine.js:14:12)",
    "/var/runtime/node_modules/aws-sdk/lib/state_machine.js:26:10",
    "Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:38:9)",
    "Request.<anonymous> (/var/runtime/node_modules/aws-sdk/lib/request.js:685:12)",
    "Request.callListeners (/var/runtime/node_modules/aws-sdk/lib/sequential_executor.js:115:18)"
  ]
}

If anyone could point in the correct direction that'd be great!

0 answers