0

im using aws dynamo db to fetch all datas from a userkyc table where kyc_status should be "A" and "D". Below code i can only use either "A" or "D". How do i fetch all data for both conditions. Help will be appreciated!

  var params = {
            TableName: "user_kyc",
            ProjectionExpression: "email, uid, kyc_status",
            KeyConditionExpression: "#kyc_status = :kyc_status",
            ExpressionAttributeNames: {
                "#kyc_status": "kyc_status",
            },
            ExpressionAttributeValues: {
                ":kyc_status": "A"
               

            },
            FilterExpression: "#kyc_status = :kyc_status"
        };

1 Answer 1

2

You could change your params to something like:

var params = {
   TableName: "user_kyc",
   ProjectionExpression: "email, uid, kyc_status",
   KeyConditionExpression: "#kyc_status = :kyc_status1 or #kyc_status = :kyc_status2",
   ExpressionAttributeNames: {
     "#kyc_status": "kyc_status",
   },
   ExpressionAttributeValues: {
     ":kyc_status1": "A",
     ":kyc_status2": "D"
   }
};

Here I added another variable, now there is :kyc_status1 and :kyc_status2, and used this now variable in KeyConditionExpression to do a or expression.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.