DynamoDB:在表达式中未使用的ExpressionAttributeNames中提供的值:键:{#date} [英] DynamoDB: Value provided in ExpressionAttributeNames unused in expressions: keys: {#date}

查看:101
本文介绍了DynamoDB:在表达式中未使用的ExpressionAttributeNames中提供的值:键:{#date}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过将 isRelevant 的值更改为 true

I am trying to update an item by changing value of isRelevant to true:

              var params = {
                  TableName: "test",
                  Key: {
                      "#date": data.Items[i].date.N,
                      "accountid": data.Items[i].accountid.S
                  },
                  UpdateExpression: "set #uu = :x",
                  ExpressionAttributeValues: {
                      ":x": {"BOOL": false}
                  },
                  ExpressionAttributeNames: {
                       '#uu': "isRelevant",
                       '#date': "date"
                  }
              };

              docClient.update(params, function(err, data) {
                  if (err) console.log(err);
                  else {
                      console.log('worked');
                  }
              });

此代码有什么问题?我尝试了所有可能的方法,但仍然无法正常工作!

What is wrong in this code? I tried all possible ways, but still not working!

推荐答案

您无需在以下项中使用属性名称映射发电机。

You don't need to use attribute name mapping for your keys in dynamo.

此刻,您读取的参数就像您有一个名为 #date的键,并且已经随机声明了一个名为 #date的属性,

At the moment you params read like you have a key called '#date' and that you've randomly declared an attribute called '#date' that you're not using.

相反,请尝试:

var params = {
  TableName: "test",
  Key: { "date": data.Items[i].date, "accountid": data.Items[i].accountid },
  UpdateExpression: "set #uu = :x",
  ExpressionAttributeValues: { ":x": false },
  ExpressionAttributeNames: { '#uu': "isRelevant" }
};

此外-使用DynamoDB.DocumentClient时,应使用JSON值,它将处理编组信息发电机类型的格式。

Also- when using DynamoDB.DocumentClient, you should use JSON values and it'll deal with the marshalling info the dynamo typed format.

这篇关于DynamoDB:在表达式中未使用的ExpressionAttributeNames中提供的值:键:{#date}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆