我想dynamoDB通过使用来获取特定项目table.getItem(xxx),并且在获取项目时需要应用一些过滤器。
select * from emp where empid=1 and isadmin=true;
如何在 dynamo-db 中编写上述查询。
下面是我尝试过的示例代码:
GetItemSpec spec = new GetItemSpec()
.withPrimaryKey("empid", "1", "deptno", "12");
Item outcome = table.getItem(spec);
System.out.pritnln("outcome "+outcome);
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我想再应用一个过滤器,例如“isAdminU=true”,请给我一些在 getItem(....) 中添加过滤器的建议。
笔记:
我可以通过使用 table.query(spec) 来解决我的使用问题,但是此方法返回集合,我每次都必须解析并获取第一个项目,这在我的情况下是不需要的。