0
votes

for some reason I want to use book.randomID as key in amazon DynamoDB table using java code. when i tried id added a new field in the item named "book.randomID"

List<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>();
        keySchema.add(new KeySchemaElement().withAttributeName("conceptDetailInfo.conceptId").withKeyType(KeyType.HASH)); // Partition

and here is the json structure

{  
   "_id":"123",
   "book":{  
      "chapters":{  
         "chapterList":[  
            {  
               "_id":"11310674",
               "preferred":true,
               "name":"1993"
            }
         ],
         "count":1
      },
      "randomID":"1234"
   }
}

so is it possible to use such element as key. if yes how can we use it as key

1

1 Answers

0
votes

When creating DynamoDB tables AWS limits it to the types String, Binary and Number. Your attribute book.random seems to be a String.

As long as it's not one of the other data types like List, Map or Set you should be fine.

Just going to AWS console and trying it out worked for me:

Table Books with nested Primary key book.randomId