Dynamodb List Type
I have problems understanding how to create a List for dynamoDB from my Android app. I can store and load the { 'deviceId': '920e185a-63ed-46ca-bfca-f7a484ccb708' } from my app.
Solution 1:
The list of map object can be created as follows. The good thing in the above structure is that all the attributes in data
is a Number. You can change it to String if needed as well. Based on your expected output, I have defined it as Long
.
Attribute Definition:-
private List<Map<String, Long>> data;
@DynamoDBAttribute(attributeName = "data")public List<Map<String, Long>> getData() {
returndata;
}
public void setData(List<Map<String, Long>> data) {
this.data = data;
}
Populate the data:-
MoviesWithData movies = newMoviesWithData();
movies.setYearKey(1917);
movies.setTitle("Tilte with list of map");
Map<String, Long> dataMap1 = newHashMap<>();
dataMap1.put("heartBeatId", 1L);
dataMap1.put("status", 1L);
dataMap1.put("timeStamp", 1502183502812L);
Map<String, Long> dataMap2 = newHashMap<>();
dataMap2.put("heartBeatId", 2L);
dataMap2.put("status", 2L);
dataMap2.put("timeStamp", 1503183502812L);
movies.setData(Arrays.asList(dataMap1, dataMap2));
dynamoDBMapper.save(movies, consistentDynamoDBMapperConfig);
Sample output:-
Post a Comment for "Dynamodb List Type"