0

I've written the following code which is using DynamoDB:

var qryItem = {
    TableName: 'MyTable',
    Key: {
        UserId: {
            S: '1234567'
        }
    }
};

dynamoDb.getItem(qryItem, function (error, data) {
    console.log(data);
    if(error){
        console.log(error, error.stack);
    }
});

The table MyTable has the following attributes:

  • UserId (String) Primary partition key
  • Name (String) Primary sort key
  • email (string)

I've successfully executed a scan operation, but when I execute the getItem request above, the following error is returned:

ValidationException: The provided key element does not match the schema

Any advice would be greatly appreciated.

1 Answer 1

2

So yeah, as always, read the documentation thoroughly before passing go.

I specified a "Sort Key" when I created the table and you MUST pass this in when you perform a query and it must be populated in order for the validation schema to get the all clear.

So my query parameters should look like:

var qryItem = {
    TableName: 'MyTable',
    Key: {
        UserId: {
            S: '1234567'
        },
        Name: {
            S: 'John Citizen'
        }
    }
};
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.