无法更新数组 aws Dynamo
Unable to update array aws Dynamo
我正在尝试更新 json array.i 在 dynamoDb.i 中有一个 table 使用 put 方法成功地将 json 数据插入到发电机中。
Partition key : _id , Type : S
这是我保存到数据库中的json数据。
{
"_id": "001",
"email": "teacher1@gmail.com",
"class": {
"student_list": []
}
}
但我无法更新 json 数组 student_list 使用键 电子邮件。
我有以下代码
var AWS = require("aws-sdk");
var docClient = new AWS.DynamoDB.DocumentClient();
var params = {
TableName: "testTable1",
Key: {
"email": "teacher1@gmail.com",
},
UpdateExpression: "set class.student_list = list_append (class.student_list, :studentEmail)",
ExpressionAttributeValues: {
":studentEmail": "manaf@gmail.com"
},
ReturnValues: "UPDATED_NEW"
};
docClient.update(params, function (err, data) {
if (err) {
console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2));
}
});
但是我收到这样的错误消息
Unable to update item. Error JSON: {
"message": "Invalid UpdateExpression: Incorrect operand type for operator or function; operator or function: list_append, operand type: S",
"code": "ValidationException",
"time": "2016-07-18T14:31:44.978Z",
"requestId": "378NSB5RVB1TNI0PB1Q3OH67V3VV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 0
}
与此相关的实际问题是什么?
来自文档:
http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Modifying.html
操作数类型必须包含在列表中。
"The new element must be contained in a list, for example to add 2 to a list, the operand would be [2]"
我正在尝试更新 json array.i 在 dynamoDb.i 中有一个 table 使用 put 方法成功地将 json 数据插入到发电机中。
Partition key : _id , Type : S
这是我保存到数据库中的json数据。
{
"_id": "001",
"email": "teacher1@gmail.com",
"class": {
"student_list": []
}
}
但我无法更新 json 数组 student_list 使用键 电子邮件。 我有以下代码
var AWS = require("aws-sdk");
var docClient = new AWS.DynamoDB.DocumentClient();
var params = {
TableName: "testTable1",
Key: {
"email": "teacher1@gmail.com",
},
UpdateExpression: "set class.student_list = list_append (class.student_list, :studentEmail)",
ExpressionAttributeValues: {
":studentEmail": "manaf@gmail.com"
},
ReturnValues: "UPDATED_NEW"
};
docClient.update(params, function (err, data) {
if (err) {
console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("UpdateItem succeeded:", JSON.stringify(data, null, 2));
}
});
但是我收到这样的错误消息
Unable to update item. Error JSON: {
"message": "Invalid UpdateExpression: Incorrect operand type for operator or function; operator or function: list_append, operand type: S",
"code": "ValidationException",
"time": "2016-07-18T14:31:44.978Z",
"requestId": "378NSB5RVB1TNI0PB1Q3OH67V3VV4KQNSO5AEMVJF66Q9ASUAAJG",
"statusCode": 400,
"retryable": false,
"retryDelay": 0
}
与此相关的实际问题是什么?
来自文档: http://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.Modifying.html
操作数类型必须包含在列表中。
"The new element must be contained in a list, for example to add 2 to a list, the operand would be [2]"