function updateRecord()

in todo-src/updateTodo/app.js [53:76]


function updateRecord(username, recordId, eventBody) {
  let d = new Date();
  const params = {
    TableName: TABLE_NAME,
    Key: {
      "cognito-username": username,
      id: recordId,
    },
    UpdateExpression: "set completed = :c, lastupdate_date = :lud, #i = :i",
    ExpressionAttributeNames: {
      // using ExpressionAttributeNames to show how to
      // overcome reserved names, in this case <item>
      "#i": "item",
    },
    ExpressionAttributeValues: {
      ":c": eventBody.completed,
      ":lud": d.toISOString(),
      ":i": eventBody.item,
    },
    ReturnValues: "ALL_NEW",
  };

  return docClient.update(params);
}