Dynamodb sdk 使用节点 js 更新地图列表中特定索引处的条目
Dynamodb sdk update entry at specific index in list in a map using node js
我正在尝试使用计数器更新特定的列表条目。
const taskParams = {
TableName: CONST.NAMES.SUJET_TABLE_NAME,
Key: {
id: defectId
},
UpdateExpression: "SET #list.#epicType.#tasks[#taskIndex].#tracking =:attrValue ",
ExpressionAttributeNames: {
'#list': 'epicsList',
'#tasks': 'tasks',
'#epicType': epicType,
'#taskIndex': taskCounter,
'#tracking': 'tracking',
},
ExpressionAttributeValues: {
':attrValue': epicData["tasks"][0]["tracking"],
},
};
try {
await documentClient.update(taskParams).promise();
console.log("Task successfully created.")
} catch (err) {
console.log("Unable to create Task ", err);
}
执行时出现以下错误:
ValidationException: Invalid UpdateExpression: Syntax error; token: "#taskIndex", near: "[#taskIndex]"
是语法错误还是有其他我不知道的地方?
我终于找到了答案,对于那些遇到这个问题的人:
const taskParams = {
TableName: CONST.NAMES.SUJET_TABLE_NAME,
Key: {
id: defectId
},
UpdateExpression: "SET #list.#epicType.#tasks[" + taskIndex+ "].#tracking =:attrValue ",
ExpressionAttributeNames: {
'#list': 'epicsList',
'#tasks': 'tasks',
'#epicType': epicType,
'#tracking': 'tracking',
},
ExpressionAttributeValues: {
':attrValue': epicData["tasks"][0]["tracking"],
},
};
我正在尝试使用计数器更新特定的列表条目。
const taskParams = {
TableName: CONST.NAMES.SUJET_TABLE_NAME,
Key: {
id: defectId
},
UpdateExpression: "SET #list.#epicType.#tasks[#taskIndex].#tracking =:attrValue ",
ExpressionAttributeNames: {
'#list': 'epicsList',
'#tasks': 'tasks',
'#epicType': epicType,
'#taskIndex': taskCounter,
'#tracking': 'tracking',
},
ExpressionAttributeValues: {
':attrValue': epicData["tasks"][0]["tracking"],
},
};
try {
await documentClient.update(taskParams).promise();
console.log("Task successfully created.")
} catch (err) {
console.log("Unable to create Task ", err);
}
执行时出现以下错误:
ValidationException: Invalid UpdateExpression: Syntax error; token: "#taskIndex", near: "[#taskIndex]"
是语法错误还是有其他我不知道的地方?
我终于找到了答案,对于那些遇到这个问题的人:
const taskParams = {
TableName: CONST.NAMES.SUJET_TABLE_NAME,
Key: {
id: defectId
},
UpdateExpression: "SET #list.#epicType.#tasks[" + taskIndex+ "].#tracking =:attrValue ",
ExpressionAttributeNames: {
'#list': 'epicsList',
'#tasks': 'tasks',
'#epicType': epicType,
'#tracking': 'tracking',
},
ExpressionAttributeValues: {
':attrValue': epicData["tasks"][0]["tracking"],
},
};