How to have FilterExpression with multiple conditions in dynamodb

I am trying to scan a table on dynamodb The following is the code that is in javascript

var params = {
    TableName: 'Contacts',
    FilterExpression: 'begins_with(CustomerName,:value)OR begins_with(CustomerName,:val) ', 
    ExpressionAttributeValues: { 
        ':value': {'S':'S'},
        ':val':{'S':'E'},
      },
    Select: 'ALL_ATTRIBUTES', 
 };

 dynamodb.scan(params, function(err, data) {
    if (err) ppJson(err); // an error occurred
    else ppJson(data); // successful response
});

But I could not try using botot3.

Below I can reach so far

response = table.scan(
                  Select= 'ALL_ATTRIBUTES',
                  FilterExpression=Attr('CustomerName').begins_with("S") 
                  )

I could not figure out how to add an OR condition. If I add, an error will appear

+4
source share
2 answers

For AND '&' and for OR '|' is used

  response = table.scan(
              Select= 'ALL_ATTRIBUTES',
              FilterExpression=Attr('CustomerName').begins_with("S") | Attr('CustomerName').begins_with("S") 
              )
+5
source

You can create the string compare = ["a = b", "c begin_with val '], and then append them to' and '.join (compare)

creating a filter expression for you: a = b and c begin_with val '

0
source

All Articles