Package com.amazonaws.services.dynamodbv2.document.utils

Examples of com.amazonaws.services.dynamodbv2.document.utils.ValueMap


    public void howToPutItems() {
        Table table = dynamo.getTable(TABLE_NAME);
        Item item = new Item()
            .withPrimaryKey(HASH_KEY_NAME, "B_PutItemJsonTest", RANGE_KEY_NAME, 1)
            // Store document as a map
            .withMap("document", new ValueMap()
                .withString("last_name", "Bar")
                .withString("first_name", "Jeff")
                .withString("current_city", "Tokyo")
                .withMap("next_haircut",
                    new ValueMap()
                        .withInt("year", 2014)
                        .withInt("month", 10)
                        .withInt("day", 30))
                .withList("children", "SJB", "ASB", "CGB", "BGB", "GTB")
            );
        table.putItem(item);
        // Retrieve the entire document and the entire document only
        Item documentItem = table.getItem(new GetItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "B_PutItemJsonTest", RANGE_KEY_NAME, 1)
            .withAttributesToGet("document"));
        System.out.println(documentItem.get("document"));
        // Output: {last_name=Bar, children=[SJB, ASB, CGB, BGB, GTB], first_name=Jeff, current_city=Tokyo, next_haircut={month=10, year=2014, day=30}}
        // Retrieve part of a document. Perhaps I need the next_haircut and nothing else
        Item partialDocItem = table.getItem(new GetItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "B_PutItemJsonTest", RANGE_KEY_NAME, 1)
            .withProjectionExpression("document.next_haircut"))
            ;
        System.out.println(partialDocItem);
        // Output: { Item: {document={next_haircut={month=10, year=2014, day=30}}} }
        // I can update part of a document. Here's how I would change my current_city back to Seattle:
        table.updateItem(new UpdateItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "B_PutItemJsonTest", RANGE_KEY_NAME, 1)
            .withUpdateExpression("SET document.current_city = :city")
            .withValueMap(new ValueMap().withString(":city", "Seattle"))
        );
        // Retrieve the entire item
        Item itemUpdated = table.getItem(HASH_KEY_NAME, "B_PutItemJsonTest", RANGE_KEY_NAME, 1);
        System.out.println(itemUpdated);
        // Output: { Item: {document={last_name=Bar, children=[SJB, ASB, CGB, BGB, GTB], first_name=Jeff, current_city=Seattle, next_haircut={month=10, year=2014, day=30}}, myRangeKey=1, myHashKey=B_PutItemJsonTest} }
View Full Code Here


            .withBoolean("booleanTrue", true)
            .withBoolean("booleanFalse", false)
            .withInt("intAttr", 1234)
            .withList("listAtr","abc", "123")
            .withMap("mapAttr",
                new ValueMap()
                    .withString("key1", "value1")
                    .withInt("key2", 999))
            .withNull("nullAttr")
            .withNumber("numberAttr", 999.1234)
            .withString("stringAttr", "bla")
View Full Code Here

        // Output: { Item: {document={next_haircut={month=10, year=2014, day=30}}} }
        // I can update part of a document. Here's how I would change my current_city back to Seattle:
        table.updateItem(new UpdateItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "howToPutItems_withJSONDoc", RANGE_KEY_NAME, 1)
            .withUpdateExpression("SET document.current_city = :city")
            .withValueMap(new ValueMap().withString(":city", "Seattle"))
        );
        // Retrieve the entire item
        Item itemUpdated = table.getItem(HASH_KEY_NAME, "howToPutItems_withJSONDoc", RANGE_KEY_NAME, 1);
        System.out.println(itemUpdated);
        // Output: { Item: {document={last_name=Bar, children=[SJB, ASB, CGB, BGB, GTB], first_name=Jeff, current_city=Seattle, next_haircut={month=10, year=2014, day=30}}, myRangeKey=1, myHashKey=B_PutItemJsonTest} }
View Full Code Here

        // Output: { Item: {next_haircut={month=10, year=2014, day=30}} }
        // I can update part of a document. Here's how I would change my current_city back to Seattle:
        table.updateItem(new UpdateItemSpec()
            .withPrimaryKey(HASH_KEY_NAME, "howToPut_TopLevelJSON", RANGE_KEY_NAME, 1)
            .withUpdateExpression("SET current_city = :city")
            .withValueMap(new ValueMap().withString(":city", "Seattle"))
        );
        // Retrieve the entire item
        Item itemUpdated = table.getItem(HASH_KEY_NAME, "howToPut_TopLevelJSON", RANGE_KEY_NAME, 1);
        System.out.println(itemUpdated);
        // Output: { Item: {first_name=Jeff, myRangeKey=1, person_id=123, current_city=Seattle, next_haircut={month=10, year=2014, day=30}, last_name=Barr, children=[SJB, ASB, CGB, BGB, GTB], myHashKey=howToPut_TopLevelJSON} }
View Full Code Here

        Table table = dynamo.getTable(TABLE_NAME);
        table.updateItem(HASH_KEY, FIRST_CUSTOMER_ID, RANGE_KEY, ADDRESS_TYPE_WORK,
            // update expression
            "set #phoneAttributeName = :phoneAtributeValue",
            new NameMap().with("#phoneAttributeName", "phone"),
            new ValueMap().withStringSet(":phoneAtributeValue",
                "123-456-7890", "987-654-3210")
            );
        GetItemOutcome outcome = table.getItemOutcome(new GetItemSpec()
            .withPrimaryKey(HASH_KEY, FIRST_CUSTOMER_ID, RANGE_KEY, ADDRESS_TYPE_WORK)
            .withConsistentRead(true));
View Full Code Here

            // update expression (list_append: concatenate two lists.)
            "set phone = list_append(:a, :b)",
            // condition expression
            "zipcode = :zipcode",
            null,
            new ValueMap()
                 .withInt(":zipcode", 98104)
                 .withList(":a", "phone-1", "phone-2")
                 .withList(":b", "phone-3", "phone-4")
         );
        outcome = table.getItemOutcome(new GetItemSpec()
View Full Code Here

            + "myRangeKey BETWEEN :lo and :hi AND "
            + "intAttr > :intAttr",
            // no attribute name substitution
            null,    
            // attribute value substitution
            new ValueMap()
                .withString(":myHashKey", "foo")
                .withInt(":lo", 1).withInt(":hi", 10)
                .withInt(":intAttr", 1238)
        );
        int count = 0;
View Full Code Here

            + "#myRangeKey BETWEEN :lo and :hi AND "
            + "intAttr > :intAttr",
            // attribute name substitution
            new NameMap().with("#myRangeKey", "myRangeKey"),
            // attribute value substitution
            new ValueMap()
                .withString(":myHashKey", "foo")
                .withInt(":lo", 1).withInt(":hi", 10)
                .withInt(":intAttr", 1238)
        );
        int count = 0;
View Full Code Here

            // attribute name substitution
            new NameMap()
                .with("#myRangeKey", "myRangeKey")
                .with("#binary", "binary"),
            // attribute value substitution
            new ValueMap()
                .withString(":myHashKey", "foo")
                .withInt(":lo", 1).withInt(":hi", 10)
                .withInt(":intAttr", 1238)
        );
        int count = 0;
View Full Code Here

            // filter expression
            "intAttr > :intAttr",
            // no attribute name substitution
            null,    
            // attribute value substitution
            new ValueMap().withInt(":intAttr", 1238));
        // can be notified of the low level result if needed
        col.registerLowLevelResultListener(new LowLevelResultListener<QueryOutcome>() {
            @Override
            public void onLowLevelResult(QueryOutcome outcome) {
                System.out.println(outcome);
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.document.utils.ValueMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.