我将字符串数组插入DynamoDB:
[13, 12, 12, 4]
当我在DynamoDB中查看时,它变成对象数组:
[ { "S" : "13" }, { "S" : "12" }, { "S" : "12" }, { "S" : "4" }]
合理吗?我需要做些什么使我的数据作为字符串数组插入?
这是我将数组放入DynamoDB的方法:
var params = {
TableName: "MatchDate",
Item:{
position: [1, 3, 4, 5]
}
};
DynamoDBClient.put(params, function(err, data) {
//Some other code
});
最佳答案
如果要使用单个对象(字符串数组),则需要将属性类型设置为String Set
然后你会得到
"SS": ["13", "12" ,"12", "4"]
或者您可以使用数字集
"NS": ["13", "12" ,"12", "4"]
编辑:在nodejs中尝试类似的方法
var params = {
TableName: "MatchDate",
Item: {
"position": {
SS: [
'12',
'13',
'4'
]
}
};
DynamoDBClient.put(params, function(err, data) {
//Some other code
});
在此处查看AWS Refernce of Javascript putItem