AbacusUtil Docs | Download | Javadoc | FAQ | Community

DynamoDBExecutor

DynamoDBExecutor is a wrapper of DynamoDB Java client. Just like SQLExecutor, it makes things much easier to operate data with DynamoDB by the straight support of Entity/String, and almost all the java basic types: boolean...double...String...Date...Calendar.... Rather than introducing something new or different, DynamoDBExecutor is created to make things simpler. Here is a simple sample:

public void test_crud() {
    Account account = createAccount();

    // create
    dbExecutor.putItem("account", toItem(account));

    // read
    Map<String, AttributeValue> key = asKey("id", account.getId());
    Account dbAccount = dbExecutor.getItem(Account.class, "account", key);
    N.println(dbAccount);

    // query
    QueryRequest queryRequest = new QueryRequest("account").withKeyConditions(Filters.eq("id", "abc123"));
    List<Account> accounts = dbExecutor.query(Account.class, queryRequest);
    N.println(accounts);

    // update
    dbExecutor.updateItem("account", key, asUpdateItem("firstName", "newFirstName"));

    // delete
    dbExecutor.deleteItem("account", key);
}

Try it now. Here are the steps: