Amazon dynamodb 更新DynamoDB中的项时出现错误,使用NodeJS更新表达式无效

Amazon dynamodb 更新DynamoDB中的项时出现错误,使用NodeJS更新表达式无效,amazon-dynamodb,Amazon Dynamodb,这是我的处理函数 const updateOrder = (request) => { const id = request.pathParams.id; const orderObject = request.body; if(!id || !orderObject) throw new Error ('Please provide required id and object in order to update the order')

这是我的处理函数

const updateOrder = (request) => {
    const id = request.pathParams.id;
    const orderObject = request.body;
    if(!id || !orderObject)
        throw new Error ('Please provide required id and object in order to update the order')


        const params = {
            TableName: "pizza-order",
            Key: {
                "orderId": id
            },
            UpdateExpression: "SET  #n = :n, #a = :a ",
            ExpressionAttributeNames: {
                "#n": "pizza",
                "#a": "address"
            },
            ConditionExpression: '' ,
            ExpressionAttributeValues: { 
                ":n": orderObject.pizza,
                ":a": orderObject.address,
            },
            
        };

        return docClient.update(params).promise()

}
订单对象为:

{
    "pizza":"THe outstanding pizza",
    "Address": "feni"
}

它返回这样的错误。我不知道为什么会这样。对于无服务器开发来说是非常新的。有人知道解决办法吗?

这是一个非常愚蠢的错误。order对象中首先有一个输入错误:

{
    "pizza":"THe outstanding pizza",
    "address": "feni" //previously it was Address: "feni
}
第二个原因是ConditionExpression不能为空

const updateOrder = (request) => {
    const id = request.pathParams.id;
    const orderObject = request.body;
    if(!id || !orderObject)
        throw new Error ('Please provide required id and object in order to update the order')

        const params = {
            TableName: "pizza-order",
            Key: {
                "orderId": id
            },
            UpdateExpression: "SET  #n = :n, #a = :a ",
            ExpressionAttributeNames: {
                "#n": "pizza",
                "#a": "address"
            },
            ConditionExpression: '' , // this can not be empty
            ExpressionAttributeValues: {
                ":n": orderObject.pizza,
                ":a": orderObject.address,
            },
            
        };

        return docClient.update(params).promise()

}