gpt4 book ai didi

amazon-dynamodb - 如何在dynamodb中具有多个条件的FilterExpression

转载 作者:行者123 更新时间:2023-12-04 00:26:15 26 4
gpt4 key购买 nike

我正在尝试在dynamodb上进行表扫描
以下是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
});


但是我无法使用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")
)

关于amazon-dynamodb - 如何在dynamodb中具有多个条件的FilterExpression,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37720073/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com