如何使用Apache骆驼扫描dynamodb表

如何使用Apache骆驼扫描dynamodb表

本文介绍了如何使用Apache骆驼扫描dynamodb表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个骆驼的api,可以扫描DynamoDb表.代码就像这样->

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&region=us-east-1&operation=Scan")
  .endRest();

这将返回表中的所有项目.我的问题是如何根据特定条件扫描表.在骆驼文档中,假设有一个为了实现针对我的问题的解决方案,需要设置类型为Map<String, Condition>的标头CamelAwsDdbScanFilter.我有一个用户表,并假设我想使用FirsName = Will检索所有用户.我如何实现Map<String, Condition>来实现这一目标?基本上,我不确定要在地图的Condition中放置什么内容.

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.

推荐答案

您可以在 ScanCommandTest .

对于条件FirstName eq Will,过滤器可能类似于:

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")));
}});

这篇关于如何使用Apache骆驼扫描dynamodb表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 04:50