[英]DynamoDB Array of String becomes Array of Objects
I insert an array of string to DynamoDB: 我将字符串数组插入DynamoDB:
[13, 12, 12, 4]
It becomes Array of Objects when I view it in DynamoDB: 当我在DynamoDB中查看时,它变为对象数组:
[ { "S" : "13" }, { "S" : "12" }, { "S" : "12" }, { "S" : "4" }]
Is it reasonable? 合理吗? Do I need to do something to make my data being inserted as array of string?
我需要做些什么使我的数据作为字符串数组插入?
Here is how I put my array to DynamoDB: 这是我将数组放入DynamoDB的方法:
var params = {
TableName: "MatchDate",
Item:{
position: [1, 3, 4, 5]
}
};
DynamoDBClient.put(params, function(err, data) {
//Some other code
});
If you want a single object (an array of strings) you need to set your attribute type to String Set 如果要单个对象(字符串数组),则需要将属性类型设置为String Set
Then you will get 然后你会得到
"SS": ["13", "12" ,"12", "4"]
Or you can use Number Set 或者您可以使用数字集
"NS": ["13", "12" ,"12", "4"]
EDIT: Try something like this in nodejs 编辑:在nodejs中尝试类似的方法
var params = {
TableName: "MatchDate",
Item: {
"position": {
SS: [
'12',
'13',
'4'
]
}
};
DynamoDBClient.put(params, function(err, data) {
//Some other code
});
Check here for AWS Refernce of Javascript putItem 在此处检查Java引用putItem的AWS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.