Wednesday, 7 June 2017

DynamoDB update item in case of item's value

Im trying to write a query which update the item only if value "taken" attribute doesn't equal "yes". Is it possibile to do that using dynamoDB? Right now dynamoDB doesn't check the condition. It updates my item and doesn't check if "taken" doesn't equal "yes"

  var params = {
      TableName:"usersRinger1",
      Key:{
          "userID": self.event.session.user.userId,
          "medicine": User.USERNAME.current.lastDrug
        },
        ConditionExpression: ':p <> :u',
        UpdateExpression: "set info.taken = :r, info.whatTime=:a",
        ExpressionAttributeValues:{
            ":r": "yes",
            ":a": actualTime,
            ':p' : 'info.taken',
            ':u' : "yes"
        },
        ReturnValues:"UPDATED_NEW"
    };
    docClient.update(params, function(err, data) {
  });



via Anna K

No comments:

Post a Comment