gpt4 book ai didi

node.js - 更新 dynamoDB 中的数组项

转载 作者:太空宇宙 更新时间:2023-11-04 00:37:57 25 4
gpt4 key购买 nike

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

 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_append(html, :html)。 ExpressionAttributeValues 只是从 :html 到您要添加的字符串的映射。

关于node.js - 更新 dynamoDB 中的数组项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38127828/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com