0

I'm using Dynamodb with the DynamoDB npm package and when I want to update data inside my Warehouse table I get the following error. It will update my data but suddenly crashes with a nonsense error. What's the problem?

ValidationException: Invalid KeyConditionExpression: An expression attribute value used in expression is not defined; attribute value: :name

Code:

let updateData = {
  customer: 'mrpen',
  name: warehouseInfo.name,
  street1: warehouseInfo.street1 ? warehouseInfo.street1 : 'N/A',
  street2: warehouseInfo.street2 ? warehouseInfo.street2 : 'N/A',
  city: warehouseInfo.city ? warehouseInfo.city : 'N/A',
  state: warehouseInfo.state ? warehouseInfo.state : 'N/A',
  country: warehouseInfo.country,
  zip: warehouseInfo.zip ? warehouseInfo.zip : 'N/A',
  contactName: warehouseInfo.contactName ? warehouseInfo.contactName : 'N/A',
  contactEmail: warehouseInfo.contactEmail ? warehouseInfo.contactEmail : 'N/A',
  contactPhone: warehouseInfo.contactPhone ? warehouseInfo.contactPhone : 'N/A',
  inventoryName: data[0].attrs.inventoryName,
};
const res = Warehouse.update(updateData, (err, res) => {
   if (err) {
    throw new Error('update warehouse failed!');
   } else {
    console.log(res);
    return true;
  }
});

1 Answer 1

1

The name attribute is one of the reserved words in DynamoDB. You can either rename the attribute or define an expression attribute name to use in the place of the reserved word.

More info on expression attributes in the docs.

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.