如何有FilterExpression在dynamodb
问题描述:
我试图做dynamodb 表扫描多个条件下面是这是在JavaScript如何有FilterExpression在dynamodb
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
});
但我不能尝试使用botot3相同的代码。
下面是我能做到到目前为止
response = table.scan(
Select= 'ALL_ATTRIBUTES',
FilterExpression=Attr('CustomerName').begins_with("S")
)
我无法理解如何添加OR条件。如果我添加,它显示错误
答
对于AND'&'被使用,对于OR'|'使用
response = table.scan(
Select= 'ALL_ATTRIBUTES',
FilterExpression=Attr('CustomerName').begins_with("S") | Attr('CustomerName').begins_with("S")
)
答
您可以创建一个字符串比较= [ “A = B”,“C BEGINS_WITH VAL '],然后用加入他们' 和”。加入(比较)
为您创建过滤表达式'a = b和c starts_with val'
这是什么来源?,谢谢 –
@Joe我不明白你在问什么 – JithPS
boto3文档很难得到,谢谢反正 –