问题
I have a camel rest api which scans a DynamoDb table. The code is like so ->
.post("dynamodb-scan-table")
.route()
.toD("aws2-ddb://user?accessKey=insert&secretKey=insert®ion=us-east-1&operation=Scan")
.endRest();
This returns all the items in my table. My problem is how to scan the table based on a certain condition. In the camel docs, it is given that there is a header CamelAwsDdbScanFilter
which is of the type Map<String, Condition>
needs to be set in order to achieve the solution for my problem. I have a table of users and suppose I want to retrieve all the users with FirsName = Will
. How do I implement the Map<String, Condition>
in order to achieve this? Basically I am not sure what to put in the Condition
of the map.
回答1:
You can find example usage in ScanCommandTest.
For condition FirstName
eq Will
the filter could be something like:
exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, new HashMap<String, Condition>(){{
put("FirsName", new Condition()
.withComparisonOperator(ComparisonOperator.EQ)
.withAttributeValueList(new AttributeValue().withS("Will")));
}});
来源:https://stackoverflow.com/questions/63124977/how-to-scan-a-dynamodb-table-using-apache-camel