简体   繁体   中英

DynamoDB Nodejs ConditionalExpresion attribute_exists - Error in validation

i am programming in nodejs and i am trying to make an update request in dynamoDB that should execute only if a conditional expression validate to true . For that, I check if in the request body object (parsedBody) there is a key called crypto.

So, this is part of my code (docClient is an instance of AWS.dynamoDB...):

在此处输入图像描述

However, if I execute this code, I got this error here:

在此处输入图像描述

So, please, can someone explain to me what am I getting wrong here?

Cheers, Marcelo

EDIT:

From AWS Docs,

"You specified a condition that evaluated to false. For example, you might have tried to perform a conditional update on an item, but the actual value of the attribute did not match the expected value in the condition."

So the behavior is correct.

You can try to use https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Expressions.UpdateExpressions.html to update an Item just in case your condition is satisfied.


The conditional expression is executed on Dynamo side and not on your server.

I think the object persedBody does not exists on DB, so you could try to pass just the 'crypto' as argument of the attribute_exists function.

Something like: ConditionalExpression: 'attribute_exists(crypto)'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM