Amazon dynamodb dynamoDB查询:从myList中用户ID所在的mytable中选择*

Amazon dynamodb dynamoDB查询:从myList中用户ID所在的mytable中选择*,amazon-dynamodb,Amazon Dynamodb,我正在将mySQL迁移到DynamoDB。在mySQL中,我有 SELECT * FROM mytable WHERE userId IN myList 如何在DynamoDB中实现它 谢谢您可以在操作上使用,以获得与上面的SQL查询相同的结果。例如,如果在Java中使用文档SDK,则可以编写以下代码: final Table table = new Table(AmazonDynamoDBClient.builder().withRegion(Regions.US_EAST_1).build

我正在将mySQL迁移到DynamoDB。在mySQL中,我有

SELECT * FROM mytable WHERE userId IN myList
如何在DynamoDB中实现它

谢谢

您可以在操作上使用,以获得与上面的SQL查询相同的结果。例如,如果在Java中使用文档SDK,则可以编写以下代码:

final Table table = new Table(AmazonDynamoDBClient.builder().withRegion(Regions.US_EAST_1).build(), "mytable");
//convert the Iterable<Item> returned by table.scan() to a stream of Items
StreamSupport.stream(
        // list however many items you need to test after IN
        table.scan(new ScanSpec().withFilterExpression("userId IN :u1, :u2")
                //define the values of the set of usernames you are testing in the list avove
                .withValueMap(ImmutableMap.of(":u1", "robert", ":u2", "daniel"))).spliterator(), false)
        //do useful stuff with the result set
        .map(Item::toJSONPretty)
        .forEach(System.out::println);
final Table Table=新表(AmazonDynamoDBClient.builder().withRegion(Regions.US_EAST_1.build(),“mytable”);
//将table.scan()返回的Iterable转换为项目流
StreamSupport.stream(
//列出输入后需要测试的项目数量
table.scan(新的ScanSpec().withFilterExpression(“userId IN:u1,:u2”)
//在列表avove中定义要测试的用户名集的值
.withValueMap(ImmutableMap.of(“:u1”,“robert”,“:u2”,“daniel”))).spliterator(),false)
//对结果集执行有用的操作
.map(项::toJSONPretty)
.forEach(System.out::println);

Userid是一个普通属性,还是定义为dynamodb表的哈希或排序键?