Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 更新dynamoDB中的数组项_Node.js_Amazon Dynamodb - Fatal编程技术网

Node.js 更新dynamoDB中的数组项

Node.js 更新dynamoDB中的数组项,node.js,amazon-dynamodb,Node.js,Amazon Dynamodb,在mydynamoDB中,我有一个表,其结构如下所示: var params = { "TableName" : "pdfs", "Item" : { pdfid: // Partition key html: [] // array attribute } }; 我可以插入新的数组数据,就像给定的代码一样: 插入阵列数据 var params = { "TableName" : "pdfs",

在mydynamoDB中,我有一个表,其结构如下所示:

 var params = {
      "TableName" : "pdfs",
      "Item" : {
          pdfid:  // Partition key
          html: [] // array attribute
       }
 };
我可以插入新的数组数据,就像给定的代码一样:

插入阵列数据

 var params = {
      "TableName" : "pdfs",
      "Item" : {
          pdfid: pdfid,
          html: [event.html]   // here "html" is an array, I just insert first array data
       }
 };

 dc.put(params, function(err, data) {
     ............................
 });
如何在
dynamoDB
中更新数组

  var params = {
      TableName: "pdfs",
      Key: {
         pdfid: event.pdfid
      },
      UpdateExpression: "SET html = :html",
      ExpressionAttributeValues: {
         ":html": ??????
      },
      ReturnValues: "ALL_NEW"
  };

使用以下UpdateExpression将值追加到列表中:
SET html=list\u append(html,:html)
。expressionAttributeValue只是从
:html
到要添加的字符串的映射。

使用字符串集属性更新列表

ExpressionAttributeValues: {
         ":html": {
              SS: aws.StringSlice(your_html_array)    
      }

如果html是字符串数组,那么应该使用StringSet数据类型,然后在UpdateExpression中使用ADD